发布于 

Linux一些常用命令

nginx

配置文件路径
1
2
/etc/nginx/nginx.conf
/etc/nginx/sites-available/default
验证配置文件
1
nginx -t
刷新配置文件
1
nginx -s reload
其他
操作 命令
启动 Nginx sudo systemctl start nginx
停止 Nginx sudo systemctl stop nginx
重启 Nginx(强制) sudo systemctl restart nginx
平滑重载配置 sudo systemctl reload nginx
查看 Nginx 状态 sudo systemctl status nginx
检查配置语法 nginx -t
查看配置文件路径 nginx -V(查看 --conf-path

https证书

安装环境
1
2
sudo apt update
sudo apt install certbot python3-certbot-nginx
生成证书

在申请证书前,请确保要申请的域名(例如 example.com 或 www.example.com )已经解析到服务器的 IP 地址,否则验证会失败

1
sudo certbot --nginx -d xx.com -d mail.xx.com -d www.xx.com

有几个域名就-d几次,根据上面nginx配置的域名示例

1
sudo certbot --nginx -d home.kretest.com -d www.kretest.com -d backend.kretest.com -d kretest.com -d mail.xx.com -d teman.kretest.com

查看内存使用

1
free -h

查看日志

1
2
tail -f xxx.log
tail -100f xxx.log

搜索日志

1
grep -C 3 "开始BC匹配" info.log

查看硬盘使用

1
df -h

查看硬盘使用排序

1
du -h --max-depth=1 / | sort -hr | head -n 10

查看硬盘使用排序,指定文件夹

/data 是文件夹 可替换为具体的

1
du -h --max-depth=1 /data | sort -hr | head -n 10