Essential Linux Command‑Line Tricks to Boost Your Productivity
This guide compiles essential Linux command‑line shortcuts and utilities—from basic bash navigation and SSH key management to powerful tools like xargs, parallel, awk, and system monitors—offering practical examples and code snippets that help users streamline workflows and boost productivity.
Basic Commands
Familiarize yourself with core bash features: read the entire bash man page, master VIM, and set up password‑less SSH using ssh-agent and ssh-add. A sample script for copying an SSH public key without a password:
$ cat nopasswd
#!/bin/sh
scp ~/.ssh/id_dsa.pub $1@$2:~/ssh
$1@$2 "touch ~/.ssh/authorized_keys ; cat ~/id_dsa.pub >> ~/.ssh/authorized_keys; chmod 644 ~/.ssh/authorized_keys; exit"Common file‑management commands include ls, chmod, chown, du, df, mount. Network utilities such as ipconfig, ifconfig, and dig are also covered.
Some Bash Expressions
Quickly repeat the previous command with !!, retrieve the last argument with !$, generate numeric ranges using {a..b}, and access script parameters via ${1-9}, $0, $#, $?, $$, and $*.
Everyday Commands
Use Ctrl‑R to search command history, Ctrl‑W, Ctrl‑U, and Alt‑BackSpace for editing, and cd - to return to the previous directory. Powerful tools like xargs and parallel enable batch processing:
find . -name *.py | xargs grep some_function
cat hosts | xargs -l {} ssh root@{} hostnameData Processing
Sorting and deduplication with sort and uniq (including -u and -d) allow set operations. Example union, intersection, and difference:
cat a b | sort | uniq > c # union
cat a b | sort | uniq -d > c # intersection
cat a b | sort | uniq -u > c # a \ b (difference)Use LC_ALL=C to speed up locale‑sensitive tools. Text manipulation with awk and sed can perform complex replacements; an awk one‑liner to sum the third column:
awk '{ x += $3 } END { print x }'Other useful utilities: cut, paste, join, shuf, sort -k for multi‑field sorting, and redirection operators >, 2>&1 to capture stdout and stderr.
System Debugging
Monitor resources with iostat, netstat, top, htop, dstat, free, and vmstat. Diagnose processes using pstree -p, pgrep, pkill, and send signals such as kill -3 <pid> for Java stack traces.
Network troubleshooting tools include mtr, traceroute, iftop, nethogs, and advanced packet analysis with wireshark or tshark. For binary inspection, use hd, bvi, strings, and grep. Examine shared libraries with ldd, debug programs with gdb, and explore the /proc filesystem for live process information.
Historical performance can be reviewed with sar, while deeper profiling is possible via stap, perf, strace, and ltrace. The dmesg log helps identify hardware or driver issues.
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.
