0.获取前置信息
确认占用端口服务
bash
1)提权到root用户
sudo -s
2)查找端口对应服务和进程号
netstat -tunlp | grep 'port'
lsof -i :port
1.systemd自启动项关闭
常规服务关闭
bash
0)查看所有systemd自启动服务
systemctl list-unit-files --state=enabled
1)关闭服务自启动
systemctl disable 'service_name' --now
2)关闭对应进程
kill -9 PID
3)查看对应服务状态
systemctl status service_name
防火墙封禁端口(可选)
bash
1)封禁端口,并重载
firewell-cmd --permanent --remove-port='port'/tcp
firewell-cme --reload
2)查看端口是否被封禁
firewell-cme --query-port='port'/tcp
2.rc.local脚本自启动排查
bash
1)检查rc.local是否存在并启用
ls -l /etc/rc*
2)注释相关服务,停止自启动
vim /etc/rc.loacl
3)禁止rc.local自启
systemctl disable rc-local --now
3.桌面自启动autostart程序关停(麒麟专属)
bash
1)查看autostart自启动程序
ls -l /etc/xdg/autostart/
2)关闭自启动项
rm -rf /etc/xdg/autostart/'进程名'.desktop
4.cron定时任务排查
bash
1)查看当前用户cron任务
crontab -l
2)查看系统级cron任务
cat /etc/crontab
ls -l /etc/cron.d
3)编辑相关任务
crontab -e
5.传统SysV init脚本排查(兼容模式)
bash
1)查看所有服务
service --status-all
2)查看某服务是否自启
chkconfig --list 服务名
3)禁止服务自启
chkconfig 服务名 off
6.日志排查(异常自启)
bash
查看系统启动日志
journalctl -b
查看某服务日志
journalctl -u 服务名