显示所有进程信息,连同命令行: ps -ef
杀死进程(等同于Ctrl+C): kill -s 2 pid
根据进程名获取PID:ps -ef | grep name | grep -v grep | awk '{print $2}'
设置变量:pid=$(ps -ef | grep name | grep -v grep | awk '{print $2}')
杀死指定进程:kill -s 2 $pid
查看systemctl日志
journalctl -u service-name.service
如无内容返回,检查
systemd-journald.service
是否正常运行
创建symlink: ln -sf source destination
重新加载nginx配置
/etc/init.d/nginx reload
Nginx服务不会终止,主进程检查配置,应用配置的过程。主进程会启动一个新的工作进程处理新来的请求。主进程发送消息给老的工作进程,通知老的进程不在接受请求,处理完现有的请求后退出(优雅退出)
重启nginx服务:systemctl restart nginx.service
重新加载systemd
配置
systemctl daemon-reload
刷新DNS缓存
sudo systemctl restart nscd
Gitlab Nginx日志:sudo gitlab-ctl tail nginx/gitlab_access.log
打包文件夹下所有文件:zip -r fileName.zip [Directory]
解压到指定文件夹: unzip -d [Directory] fileName.zip
certbot更新证书(更新重启nginx服务):certbot certonly --cert-name example.com -d example.org,www.example.org
查看磁盘使用情况: df -h
查看当前目录占用的磁盘大小: du -sh
查看当前目录下文件夹占用的磁盘大小: du --max-depth=1 -h
从远程服务器下载文件
scp -r root@server:/source/file/path /target/file/path
上传文件至远程服务器
scp -r /source/file/path root@server:/target/file/path
添加DNS
sudo vim /etc/resolvconf/resolv.conf.d/base
sudo vim /etc/resolv.conf
修改DNS服务器地址
nameserver 8.8.8.8
添加环境变量
sudo vim /etc/enviroment
source /etc/enviroment