Linux Command Cheat Sheet: Basic Operations, System Management, and Monitoring
This article provides a comprehensive collection of essential Linux command-line instructions covering system shutdown and reboot, hardware and process inspection, file manipulation, networking utilities, performance monitoring, and common administrative tasks, all organized for quick reference by developers and system administrators.
This guide compiles frequently used Linux command-line operations for developers and system administrators, offering quick reference for everyday tasks.
Basic Operations
Shutdown and reboot the system:
shutdown -h now shutdown -r nowInspect system and CPU information:
uname -a cat /proc/version env cat /proc/cpuinfoCreate symbolic links: ln -s /usr/local/jdk1.8/ jdk Manage RPM packages: rpm -qa | grep <em>package_name</em> Generate SSH keys: ssh-keygen -t rsa -C [email protected] Define command aliases: alias ll='ls -alF' Synchronize server time: sudo ntpdate -u ntp.api.bz Run commands in background with various logging options:
nohup xxx & nohup xxx > /dev/null & nohup xxx > out.log 2>&1 &Force logout of active users: pkill -kill -t <em>TTY</em> Find command location: which <em>command</em> Check maximum file descriptors: ulimit -n Configure DNS: vim /etc/resolv.conf Query domain routing: nslookup google.com View recent login information: last -n 5 Set static IP address:
ifconfig em1 192.168.5.177 netmask 255.255.255.0File and Directory Operations
Vim editing shortcuts and commands:
:%s/x/y/g 0(move to line start) $ (move to line end) shift+g (jump to file end) gg (jump to file start) :set nu (show line numbers) :set nonu (hide line numbers)
Save a read‑only file with sudo: :w !sudo tee % Disk and file size queries:
mount df du -H -h du -sh *Word count utilities:
wc -l filename wc -w filename wc -L filename wc -cCompression and extraction:
tar czvf xxx.tar zip -r xxx.zip tar zxvf xxx.tar tar zxvf xxx.tar -C /xxx/yyy/ unzip xxx.zipChange file ownership: chown eagleye.eagleye xxx.log Copy, remote copy, and directory creation:
cp xxx.log cp -f xxx.log cp -r src/ dest/ scp -P <em>port</em> user@host:/path/file /local/path mkdir -p /xxx/yyy/zzzCompare files:
diff -u 1.txt 2.txtSearch and Retrieval
Grep examples:
grep -v xxx grep -n "^$" file grep -n "^abc" file grep -c xxx file grep -i xxx fileAwk field extraction: awk -F ':' '{if ($5 ~ /user/) print $0}' /etc/passwd Find command usage:
find /home/eagleye -name "*.mysql" -print find /usr -atime 3 -print find /doc -user jacky -name 'j*' -print find /doc -name '*bak' -exec rm {} \;Network Utilities
Identify process using a port: lsof -i:port Get local IP address:
/sbin/ifconfig -a | grep inet | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}' | tr -d "addr:"iptables management:
service iptables status iptables -I INPUT -s <em>IP</em> -j DROP iptables -D INPUT -s <em>IP</em> -j DROP /sbin/iptables -I INPUT -p tcp --dport 9090 -j ACCEPTNetcat for TCP testing:
nc 192.168.0.11 8000 < data.txt nc -l 8000 > received_data nc -lk 8000Trace network routes: traceroute -I www.163.com Socket inspection with ss and netstat:
ss -l ss -pl netstat -n | awk '/^tcp/ {++state[$NF]} END {for (k in state) print k, state[k]}'Performance Monitoring
Top command sorting tips:
Press F or O then a‑z to sort, R to reverse.
Key fields of top output are described in the accompanying table.
View kernel messages: dmesg Disk I/O statistics: iostat -xz 1 Memory usage: free -m Network throughput: sar -n DEV 1 TCP connection statistics: sar -n TCP,ETCP 1 CPU, memory, and I/O monitoring with vmstat: vmstat 2 1 Interpretation of vmstat columns (r, b, swpd, free, buff, cache, si, so, bi, bo, in, cs, us, sy, id, wa) is provided for performance analysis.
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.
Sohu Tech Products
A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.
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.
