常用linux命令 centos7系统

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38165374/article/details/82812544
du -sh /scripts 查看文件大小
find /logs/ -mtime +3 -type f  -name '*.log'|sort|xargs rm -f 删除3天前的日志
ps -ef | grep python | grep -v grep | awk '{print $2}' | xargs kill -9  杀掉以python开头的进程
netstat -tunlp  查看端口号
lsof -i tcp:port 查看占用端口号的进程 需要安装 yum install lsof
grep error error.log|grep -v grep|wc -l 查看error.log文件中包含error字符串的个数
ps -eo  pid,tty,user,comm,etime|grep -v grep|grep node|awk '{split($5,runtime,":"); if (runtime[3] != "" && runtime[1]>=3) print $1}'|xargs kill -9  杀掉运行时间大于3个小时的进程
diff 文件1 文件2 比较两个文件
scp -r 文件名 用户@ip:远程服务器路径  本地文件推送到服务器
scp 用户名@ip:远程服务器路径  ./ 将服务器上的文件下载到本机当前路径
ssh root@ip 链接远程服务器
编辑 .bashrc 文件 添加 alias ssh-server='ssh root@ip' 执行 source .bashrc 之后可以直接终端输入 ssh-server 链接到远程服务器

猜你喜欢

转载自blog.csdn.net/qq_38165374/article/details/82812544