Operations 10 min read

Master Essential Linux Commands for Efficient System Operations

This article shares practical Linux command techniques—including xargs, background execution, process monitoring, multitail, continuous ping logging, TCP state inspection, and SSH port forwarding—to help system administrators streamline tasks, improve script efficiency, and troubleshoot performance issues.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Essential Linux Commands for Efficient System Operations

I have spent years in operations, starting with simple commands and overly long scripts, and later discovering advanced tools like xargs, pipelines, and auto‑response commands, which inspired me to document useful Linux commands for future reference.

01 Practical xargs Command

Why xargs matters

The xargs command can take the output of one command and feed it as arguments to another, simplifying tasks such as classifying files.

Example: find all # find / -name *.conf -type f -print | xargs file Output is shown in the image below.

Using xargs with

# find / -name *.conf -type f -print | xargs tar cjf test.tar.gz

can directly archive the found files.

02 Running Commands or Scripts in Background

Long‑running operations like database import/export should survive terminal disconnection.

Example with

# nohup mysqldump -uroot -pxxxxx --all-databases > ./alldatabases.sql &

(password in clear text) or without & and then using Ctrl+Z followed by bg to background the job.

The command creates a nohup.out file in the current directory containing execution logs.

03 Find Processes with High Memory Usage

Command:

# ps -aux | sort -rnk 4 | head -20

The fourth column shows memory usage percentage; the last column shows the corresponding process.

04 Find Processes with High CPU Usage

Command:

# ps -aux | sort -rnk 3 | head -20

The third column shows CPU usage percentage; the last column shows the corresponding process.

05 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.rpm

multitail supports syntax highlighting, filtering, and more.

Example: monitor

# multitail -e "Accepted" /var/log/secure -l "ping baidu.com"

06 Continuous Ping and Log Results

Command:

ping api.jpush.cn | awk '{print $0 "    " strftime("%Y-%m-%d %H:%M:%S",systime())}' >> /tmp/jiguang.log &

The output is appended to /tmp/jiguang.log each second.

07 View TCP Connection Status

Command:

# netstat -nat | awk '{print $6}' | sort | uniq -c | sort -rn

08 Find Top 20 IPs Requesting Port 80

Command:

# netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20

09 SSH Port Forwarding Example

SSH can forward ports securely.

Scenario: forward local port 9200 on a bastion host (192.168.1.15) to Elasticsearch server (192.168.1.19:9200).

Command:

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 (key exchange must be set up beforehand).

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

OperationsLinuxcommand-lineNetworkingSystem AdministrationShell scripting
MaGe Linux Operations
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.