Boost Your Linux Ops: Master Xargs, Background Jobs, and Advanced Monitoring Tricks
This guide walks Linux operators through practical uses of xargs, background execution with nohup, memory and CPU process ranking, multitail log aggregation, continuous ping logging, TCP state inspection, top‑IP discovery, and SSH port forwarding, each illustrated with real commands and output screenshots.
Introduction
The author shares years of ops experience and compiles useful advanced Linux commands for personal reference and to help others.
1. Practical xargs Command
Use xargs to feed the output of one command as arguments to another. Example: find all .conf files and classify them with file:
# find / -name *.conf -type f -print | xargs fileOutput screenshot:
Another example packs the found files directly with tar:
# find / -name *.conf -type f -print | xargs tar cjf test.tar.gz2. Running Commands or Scripts in Background
Use nohup to keep a command running after the terminal closes, e.g., exporting all MySQL databases:
# nohup mysqldump -uroot -pYOUR_PASSWORD --all-databases > ./alldatabases.sql &If you prefer to enter the password interactively, run the command without &, then suspend with Ctrl+Z and resume in background with bg. The command creates a nohup.out file with logs.
3. Find Processes with High Memory Usage
Sort processes by memory percentage and show the top 20:
# ps -aux | sort -rnk 4 | head -204. Find Processes with High CPU Usage
Sort processes by CPU percentage and show the top 20:
# ps -aux | sort -rnk 3 | head -205. View Multiple Logs Simultaneously with multitail
Install multitail:
# wget ftp://ftp.is.co.za/mirror/ftp.rpmforge.net/redhat/el6/en/x86_64/dag/RPMS/multitail-5.2.9-1.el6.rf.x86_64.rpm
# yum -y localinstall multitail-5.2.9-1.el6.rf.x86_64.rpmExample: monitor /var/log/secure for the keyword “Accepted” while simultaneously showing live ping output:
# multitail -e "Accepted" /var/log/secure -l "ping baidu.com"6. Continuous Ping with Logging
Record a timestamped ping result every second:
ping api.jpush.cn | awk '{print $0 " " strftime("%Y-%m-%d %H:%M:%S",systime())}' >> /tmp/jiguang.log &The log file grows with one entry per second:
7. Check TCP Connection States
Show the count of connections per state for port 80:
# netstat -nat | awk '{print $6}' | sort | uniq -c | sort -rn8. Top 20 IPs Requesting Port 80
Identify the most frequent source IPs for port 80:
# netstat -anlp | grep 80 | grep tcp | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n209. SSH Port Forwarding
Forward local port 9200 on a bastion host to a remote Elasticsearch instance:
ssh -p 22 -C -f -N -g -L 9200:192.168.1.19:9200 [email protected]After execution, accessing 192.168.1.15:9200 actually reaches 192.168.1.19:9200. Ensure SSH keys are exchanged beforehand.
Conclusion
The author will continue to add more useful Linux operations in future posts.
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.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
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.
