Centos 常用命令汇总
更新系统 yum update -y
删除文件 rm -rf
安装/ 安装不询问
yum install
yum -y install
移除卸载 yum remove
修改root密码 echo '密码' | passwd --stdin root
全局目录连接 ln -s 目录1 目录2
查看占用端口 netstat -tunlp
nginx重启 nginx -s reload
nginx 重启不了处置
查看nginx配置在哪 nginx -t
查看nginx运行配置生成 pid nginx -c /usr/local/nginx/config/nginx.conf
(nginx.conf 路径)
重启 nginx -s reload
查看磁盘占用 df -h
找出文件位置 which 名称
例如 which nginx
搜索文件路径或位置 whereis crontab
查看crontab定时任务日志 tail -f /var/log/cron
/sbin/service crond start //启动crontab服务
service crond start //启动crontab服务
/sbin/service crond stop //关闭crontab服务
service crond stop //关闭crontab服务
/sbin/service crond restart //启动crontab服务
service crond restart //启动crontab服务
/sbin/service crond reload //重新载入配置
service crond status //查看crontab服务状态
1.按照文件名查找
在根目录下查找文件httpd.conf,表示在整个硬盘查找
find / -name httpd.conf
在/etc目录下文件httpd.conf
find /etc -name httpd.conf
使用通配符*表示在/etc目录下查找文件名中含有字符串’abc’的文件
find /etc -name *abc
表示当前目录下查找文件名开头是字符串’abc’的文件
find . -name 'abc*'
2.按照文件特征查找
查找在系统中最后10分钟访问的文件(access time)
find / -amin -10
查找在系统中最后48小时访问的文件
find / -atime -2
查找在系统中为空的文件或者文件夹
find / -empty
查找在系统中属于 group为cat的文件
find / -group cat
查找在系统中最后5分钟里修改过的文件(modify time)
find / -mmin -5
查找在系统中最后24小时里修改过的文件
find / -mtime -1
查找在系统中属于abc这个用户的文件
find / -user abc
查找出大于10000000字节的文件(c:字节,w:双字,k:KB,M:MB,G:GB)
find / -size +10000c
查找出小于1000KB的文件
find / -size -1000k