Essential Linux Incident‑Response Commands for Quick Threat Detection
This guide walks through common Linux emergency scenarios—such as mining malware, ransomware, and backdoors—detailing a step‑by‑step workflow and providing essential command‑line tools for process, user, network, and file investigation on CentOS 6 and Windows Server 2008 systems.
Introduction
Linux emergency response is a core focus in the security field, but the full‑command‑line interface can make troubleshooting cumbersome. This article consolidates practical notes and commands for handling typical incidents on CentOS 6 (Linux) and Windows Server 2008 (Windows).
Common Emergency Issues
Mining malware (cryptocurrency miners)
Webshells (often referred to as “菠菜” in Chinese)
Ransomware – check for decryption tools from 360, Tencent, etc.; if none, reinstall the system.
Basic Workflow
Receive the emergency directive and travel to the client site with a laptop.
Communicate with the client to gather information, determine the problem, and possibly log in to the target machine for investigation.
Typical steps: Identify the problem → Resolve the problem → Write a report .
There is a saying: “scan for one minute, report for one hour.” When dealing with webshells, pay special attention to modified web‑server configuration files or injected links.
Process Inspection Commands
These commands help you discover malicious processes.
1. View real‑time system status
topcontinuously monitors process information. Mining malware usually shows high CPU usage.
2. View a snapshot of processes
psdisplays instant process data. Common options: -a: show all processes on the current terminal, including other users. -e: display environment variables for each process. -f: show UID, PPID, C, STIME columns.
3. Show non‑root processes
ps -U root -u root -N4. Show root‑owned processes
ps -u root5. Find suspicious processes
ps -aef | grep inetd grepsearches; inetd is a Linux daemon.
6. Detect hidden processes
ps -ef | awk '{print}' | sort -n | uniq > 1 ls /proc | sort -n | uniq > 2 sort -nsorts numerically; uniq removes duplicate lines.
7. List system cron jobs
ls /etc/crontabUser and Activity Inspection
1. Who is logged in?
who2. Show login IPs
who -m3. Recent login history
last -n 54. Recent command history
history 55. Find accounts with empty passwords
awk -F':' '($2=="")' /etc/shadow6. List UID 0 accounts (root) using awk
awk -F':' '($3==0)' /etc/passwd7. List UID 0 accounts using grep
grep -v -E "^#" /etc/passwd | awk -F':' '$3==0{print $1}'8. Show process tree to locate parent‑child relationships
pstree -pNetwork Inspection Commands
1. List all connections and listening ports
netstat -lntpCommon netstat options: -a or --all: show all sockets. -c or --continuous: continuously display. -i or --interfaces: show interface table. -l or --listening: show listening sockets. -n or --numeric: display numeric addresses. -t or --tcp: show TCP connections. -u or --udp: show UDP connections.
2. Identify which process uses a specific port (e.g., 22)
lsof -i :223. Show file information for multiple PIDs
lsof -p 2,34. List all TCP connections
lsof -i tcp5. List all UDP connections
lsof -i udpFile Inspection Commands
1. List all files, including hidden ones
ls -la2. Locate a file’s path
whereis filename3. Show file creation/modification time
ls -al filename4. Find files modified in the last 24 hours
find ./ -mtime 0Explanation of -mtime n: -mtime 0: modified within the last day. -mtime 1: modified 1–2 days ago. -mtime +1: modified more than 2 days ago. -mtime -1: modified less than a day ago.
5. Find files ending with .txt
find / -name "*.txt"6. Find files not ending with .txt
find / ! -name "*.txt"Conclusion
The article aggregates numerous commands useful for Linux security incident response. While the sheer volume can feel overwhelming, the structured workflow and categorized command sets provide a practical reference for analysts confronting mining malware, webshells, ransomware, or other compromises.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
