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 nowshutdown -r nowInspect system and CPU information:
uname -acat /proc/versionenvcat /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/g0(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:
mountdfdu -H -hdu -sh *Word count utilities:
wc -l filenamewc -w filenamewc -L filenamewc -cCompression and extraction:
tar czvf xxx.tarzip -r xxx.ziptar zxvf xxx.tartar zxvf xxx.tar -C /xxx/yyy/unzip xxx.zipChange file ownership: chown eagleye.eagleye xxx.log Copy, remote copy, and directory creation:
cp xxx.logcp -f xxx.logcp -r src/ dest/scp -P <em>port</em> user@host:/path/file /local/pathmkdir -p /xxx/yyy/zzzCompare files:
diff -u 1.txt 2.txtSearch and Retrieval
Grep examples:
grep -v xxxgrep -n "^$" filegrep -n "^abc" filegrep -c xxx filegrep -i xxx fileAwk field extraction: awk -F ':' '{if ($5 ~ /user/) print $0}' /etc/passwd Find command usage:
find /home/eagleye -name "*.mysql" -printfind /usr -atime 3 -printfind /doc -user jacky -name 'j*' -printfind /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 statusiptables -I INPUT -s <em>IP</em> -j DROPiptables -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.txtnc -l 8000 > received_datanc -lk 8000Trace network routes: traceroute -I www.163.com Socket inspection with ss and netstat:
ss -lss -plnetstat -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.
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.
