Practical Linux Commands for File Classification, Process Monitoring, and Network Analysis
This article demonstrates how to use xargs with find and tar for file handling, ps for identifying high‑memory and high‑CPU processes, and netstat combined with awk and sort to inspect TCP connection states and the top requesting IP addresses, providing essential command‑line techniques for system administrators.
The xargs command allows the output of one command to be used as arguments for another, simplifying many shell tasks.
Example 1 : Find all files ending with .conf under the root directory and classify them with the file utility:
find / -name *.conf -type f -print | xargs file
To archive those .conf files directly, combine find with tar via xargs :
find / -name *.conf -type f -print | xargs tar cjf test.tar.gz
2. List processes with high memory usage : Use ps piped to sort and head to show the top 20 memory‑consuming processes (the 4th column is the memory‑percentage):
ps -aux | sort -rnk 4 | head -20
3. List processes with high CPU usage : Similar command, sorting by the 3rd column (CPU percentage):
ps -aux | sort -rnk 3 | head -20
4. Check TCP connection states : Display the count of each TCP state, useful for analyzing port 80 connections:
netstat -nat | awk '{print $6}' | sort | uniq -c | sort -rn
5. Identify the top 20 IP addresses generating the most requests , which can help detect potential attacks:
netstat -anlp | grep 80 | grep tcp | awk '{print $5}' \ | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n20 The article concludes with a reminder to like, share, and follow the source for more technical content.
DevOps Operations Practice
We share professional insights on cloud-native, DevOps & operations, Kubernetes, observability & monitoring, and Linux systems.
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.