防火墙
# 临时启动防火墙(重启后失效)
systemctl start firewalld
# 永久启动防火墙(开机自启)
systemctl enable firewalld
# 同时启动并设置开机自启
systemctl start firewalld && systemctl enable firewalld
# 临时关闭防火墙(重启后失效)
systemctl stop firewalld
# 永久关闭防火墙(开机自启)
systemctl disable firewalld
# 同时关闭并取消开机自启
sudo systemctl stop firewalld && sudo systemctl disable firewalld
# 查看防火墙状态
systemctl status firewalld
# 查看防火墙开放的端口
firewall-cmd --list-ports
# 开放防火墙的指定端口
firewall-cmd --add-port=xxxx/tcp --add-port=xxxx/tcp --permanent
# 刷新防火墙配置
firewall-cmd --reload
查找文件
# 查询文件内是否包含某个字段
grep -r "查找的字段" /查找的路径 --include="匹配的文件名(可以有通配符 *)"
# 查询文件位置
find /查找的路径 -name "查找的文件名(可以有通配符 *)"
端口
# 用进程号查看所占用端口
netstat -tulnp | grep <进程ID>
文件占用
# 查看文件占用大小
# -s显示总和,-h人类可读,sort -hr按大小倒序
sudo du -sh /* | sort -hr
查看日志
# 查看文件的从上到下第N行
read -n N /xxx/xxx/xxx
# 查看文件从下到上第N行
tail -n N /xxx/xxx/xxx
# 查看文件最新日志不断刷新监控
tail -f /xxx/xxx/xxx
Linux系统事件
推荐使用shutdown,其它的不推荐
# 服务器立即关机
shutdown -h now
# 10分钟后关闭服务器
shutdown -h +10
# 当天20:00关闭服务器
shutdown -h 20:00
# 服务器立即关机
poweroff
# 关闭服务器并停止所有进程
halt
# 用于切换服务器运行级别,并关闭服务器
init 0
# 查看php状态
systemctl status php-fpm
# 启动php
systemctl start php-fpm
# 停止php
systemctl stop php-fpm


