在 Debian(或其他 Linux 系统)上“定位异常进程”,通常可以按发现异常 → 确认身份 → 定位来源 → 排查原因的步骤来做。下面给你一套实用方法。
top
# 或更好用
htop
关注:
安装 htop:
sudo apt install htop
ps aux --sort=-%cpu | head
ps aux --sort=-%mem | head
ss -antp
# 或
netstat -antp
重点看:
ps -fp <PID>
看:
ls -l /proc/<PID>/exe
cat /proc/<PID>/cmdline
异常进程常见特征:
/tmp、/dev/shmpython、bash、systemdlsof -p <PID>
systemctl status <PID>
或:
ps -o pid,ppid,user,comm -p <PID>
crontab -l
ls -l /etc/cron.*
systemctl list-unit-files --type=service
journalctl -xe
dmesg
或:
cat /var/log/syslog
last
w
who
看异常登录 IP。
dpkg -V
或对比:
which <命令>
| 现象 | 可能原因 |
|---|---|
| CPU 100% | 挖矿木马 |
| 大量网络外连 | 后门 / 僵尸网络 |
| 无名进程 | 临时脚本 |
| 父进程是 apache/nginx | Web 被入侵 |
iptables -P OUTPUT DROP
kill -9 <PID>
如果你愿意,可以:
top / ps aux 输出我可以帮你具体判断是哪个进程异常、怎么处理。