3.linux常用命令

发表于 linux 分类,标签:
--------------------------------------------------------------------------------------------------
1.安装ifconfig
yum search ifconfig
yum -y install net-tools.x86_64
--------------------------------------------------------------------------------------------------
2.安装htop
yum  -y install epel-release
yum -y install htop
--------------------------------------------------------------------------------------------------
3.删除乱码文件
查询:ls -i *
删除:find -inum 1601128 -delete
--------------------------------------------------------------------------------------------------
4.配置yum源
先备份,然后下载:http://mirrors.cloud.tencent.com/repo/centos8_base.repo
wget -O /etc/yum.repos.d/CentOS-aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo
https://mirrors.aliyun.com/centos-vault/
清理缓存后安装:yum clean all,yum makecache
--------------------------------------------------------------------------------------------------
4.grep
rm-bp1bmtw9en37y333x.mysql.rds.aliyuncs.com
rm-bp1bmtw9en37y333xwo.mysql.rds.aliyuncs.com
redis.rds.aliyuncs.com
grep -r -l "backup_crontab.sh" /root	搜索文件夹
grep "" * -nR --exclude-dir={.*} -type f	排除某个文件夹
grep "mysql.rds.aliyuncs.com" /root -nR
grep "redis.rds.aliyuncs.com" /root -nR
--------------------------------------------------------------------------------------------------
5.批量管理docker
docker中 启动所有的容器命令
docker start $(docker ps -a | awk '{ print $1}' | tail -n +2)
docker中 关闭所有的容器命令
docker stop $(docker ps -a | awk '{ print $1}' | tail -n +2)
docker中 删除所有的容器命令
docker rm $(docker ps -a | awk '{ print $1}' | tail -n +2)
docker中 删除所有的镜像
docker rmi $(docker images | awk '{print $3}' |tail -n +2)
--------------------------------------------------------------------------------------------------
6.设置免密登录
ssh-keygen -t rsa
ssh-copy-id root@121.40.95.65
cat id_rsa_pub >> .ssh/authorized_keys
--------------------------------------------------------------------------------------------------
7.查看systemctl开机程序
systemctl list-unit-files
--------------------------------------------------------------------------------------------------
8.按时间排序
find ./ -newerct '2022-12-30'
--------------------------------------------------------------------------------------------------
9.同步 es
./migrator-linux-amd64  -s http://127.0.0.1:9200  -d http://47.99.132.146:9200 -x yz_zh_searchkeyword_v1  -w=5 -b=10 -c 10000
--------------------------------------------------------------------------------------------------
10.远程登录
yum -y install sshpass
sshpass -p "Shimujiuxia@2018" ssh -o StrictHostKeyChecking=no -p 10260 root@106.13.239.3 ‘echo 1111’
--------------------------------------------------------------------------------------------------
11.递归匹配当前目录下含有字段的文件
grep -r "cdn.bootcss.com/bootstrap" .
不显示行
grep -rl "cdn.bootcss.com/bootstrap" .
不区分大小写
grep -ril "cdn.bootcss.com/bootstrap" .
--------------------------------------------------------------------------------------------------
12.刷新dns
ipconfig /flushdns
--------------------------------------------------------------------------------------------------
13.设置上海时区
# 以中国标准时区为例
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
修改时间
date -s "2022-01-01 12:00:00"
这会将系统时间设置为2022年1月1日12:00:00。
使用hwclock命令:
hwclock --set --date "2022-01-01 12:00:00"
hwclock -s
hwclock --hctosys  # 将硬件时钟同步到系统时间
--------------------------------------------------------------------------------------------------
14.安装ifconfig
yum search ifconfig
yum -y install net-tools.x86_64
--------------------------------------------------------------------------------------------------
15.安装htop
yum  -y install epel-release
yum -y install htop
--------------------------------------------------------------------------------------------------
16.全局替换
:%s/shilei/shileide
--------------------------------------------------------------------------------------------------
17.查看历史重启时间
last reboot | less
--------------------------------------------------------------------------------------------------
18.删除乱码文件
查询:ls -i *
删除:find -inum 1601128 -delete
--------------------------------------------------------------------------------------------------
19.解压gz文件
gunzip 文件名
--------------------------------------------------------------------------------------------------
20.配置yum源
先备份,然后下载:http://mirrors.cloud.tencent.com/repo/centos8_base.repo
wget -O /etc/yum.repos.d/CentOS-aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo
https://mirrors.aliyun.com/centos-vault/
清理缓存后安装:yum clean all,yum makecache
--------------------------------------------------------------------------------------------------
21.config-manager没有找到
-bash: yum-config-manager: command not found
dnf -y install yum-utils
yum -y install yum-utils
--------------------------------------------------------------------------------------------------
22.看内存
free -m
--------------------------------------------------------------------------------------------------
23.docker容器查看
docker status
--------------------------------------------------------------------------------------------------
24.删除所有镜像
docker rmi $(docker images -q)
--------------------------------------------------------------------------------------------------
25.grep命令
rm-bp1bmtw9en37y333x.mysql.rds.aliyuncs.com
rm-bp1bmtw9en37y333xwo.mysql.rds.aliyuncs.com
redis.rds.aliyuncs.com
grep -r -l "backup_crontab.sh" /root	搜索文件夹
grep "" * -nR --exclude-dir={.*} -type f	排除某个文件夹
grep "mysql.rds.aliyuncs.com" /root -nR
grep "redis.rds.aliyuncs.com" /root -nR
--------------------------------------------------------------------------------------------------
26.curl使用
curl "http://predict.yaozhvpc.com/predictsales?med_name=HD009302&manuf=147289785&predict_year=2023&brand_size=0.8"
/usr/bin/curl https://adminvip.yaozh.com/app_user/change_alonerule >/dev/null 2>&1
--------------------------------------------------------------------------------------------------
27.搜索zblog目录下所有含有www.tusay.net的文件
grep -rn "www.tusay.net" zblog
--------------------------------------------------------------------------------------------------
28.让显卡一直查看状态
watch -n 0.1 -d nvidia-smi
--------------------------------------------------------------------------------------------------
29.显卡状态一直后台输出
nohupnvidia-smi -l 1 &
--------------------------------------------------------------------------------------------------
30.开启嵌套虚拟化
modprobe -r kvm-intel
modprobe kvm-intel nested=1
--------------------------------------------------------------------------------------------------
31.清除本地yum缓存
createrepo ./
yum clean all
yum makecache
yum list | grep kernel
--------------------------------------------------------------------------------------------------
32.安装需求包
yum install epel-release   -y
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
rpm -Uvh epel-release*rpm
yum install lttng-ust -y
--------------------------------------------------------------------------------------------------
33.通过命令查看服务器上一共开了多少的 php-cgi 进程
ps -fe |grep "php-fpm"|grep "pool"|wc -l
查看已经有多少个php-cgi进程用来处理请求
netstat -napo |grep "php-fpm" | wc -l
--------------------------------------------------------------------------------------------------
34.pid被锁定(Existing lock /var/run/yum.pid)
yum -y install epel-release
--------------------------------------------------------------------------------------------------
35.关闭屏幕命令
xset dpms force off
--------------------------------------------------------------------------------------------------
36.设置免密登录
ssh-copy-id root@121.40.95.65
--------------------------------------------------------------------------------------------------
37.内核版本
uname -a
--------------------------------------------------------------------------------------------------        
38.redhat发行版
cat /etc/redhat-release
--------------------------------------------------------------------------------------------------
39.显示SELinux的状态
getenforce
--------------------------------------------------------------------------------------------------
40.关闭防火墙
systemctl stop firewalld
--------------------------------------------------------------------------------------------------
41.查看repos源
cat /etc/yum.repos.d/local.repo
--------------------------------------------------------------------------------------------------
42.安装epel源
yum  -y install epel-release
--------------------------------------------------------------------------------------------------
43.安装utils
yum -y install yum-utils
--------------------------------------------------------------------------------------------------
44.安装docker源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
--------------------------------------------------------------------------------------------------
45.列出docker源
yum list docker-ce --show-duplicates
yum list docker --showduplicate(centos_8)
--------------------------------------------------------------------------------------------------
46.查看docker相关包
yum list docker --show-duplicates
--------------------------------------------------------------------------------------------------
47.显示docker-ce所有可安装版本(简)
yum list docker-ce --showduplicates | sort -r
--------------------------------------------------------------------------------------------------
48.安装指定版本
yum -y install docker-ce-18.06.1.ce-3.el7
yum install -y --setopt=obsoletes=0  docker-ce-20.10.10-3.el7
yum  install docker-ce-20.10.24-3.el7 docker-ce-cli-20.10.24-3.el7 docker-ce-rootless-extras-20.10.24-3.el7 docker-compose-plugin-20.10.24-3.el7 docker-ce-cli-20.10.24-3.el7
--------------------------------------------------------------------------------------------------
49.添加开机启动项
systemctl enable docker
--------------------------------------------------------------------------------------------------
50.容器信息
docker info
--------------------------------------------------------------------------------------------------
51.tar指定目录
tar -zcvf /data/1.tar.gz dir1
tar -zxvf 1.tar.gz -C /data
--------------------------------------------------------------------------------------------------
52.udp端口测试
nc -vuz 192.168.8.250 1514
--------------------------------------------------------------------------------------------------
53.docker-compose命令
curl -SL https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
--------------------------------------------------------------------------------------------------
54.Name or service not known
vim /etc/resolv.conf
nameserver 8.8.8.8
--------------------------------------------------------------------------------------------------
55.-bash: killall: command not found
sudo yum install psmisc
--------------------------------------------------------------------------------------------------


0 篇评论

发表我的评论