Boost Your Linux Productivity: Essential Command-Line Tips & Tricks
This article compiles a comprehensive set of high‑efficiency Linux command‑line tools and shortcuts—ranging from basic Bash usage and SSH key management to powerful data‑processing utilities and system‑debugging commands—to help users streamline daily workflows and save valuable time.
Below is a curated collection of command‑line tools and techniques that are useful for everyday Linux work. For any unfamiliar command, consult its manual page with man or search online. Some commands may require installation via yum or apt‑get.
1 Basic Linux Commands
Familiarize yourself with Bash, read the entire Bash man page, and learn to use VIM as a powerful editor.
Understand SSH and password‑less authentication using ssh‑agent and ssh‑add. A typical script for setting up password‑less login is:
#!/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"Master common Bash job‑control commands such as &, Ctrl‑Z, Ctrl‑C, jobs, fg, bg, kill.
Essential file‑management commands include ls, ls -l, less, head, tail, tail -f, ln, ln -s, chmod, chown, du, df, mount.
Network utilities: ifconfig, ip, dig.
Regular‑expression tools: grep, egrep with options -o, -A, -B.
Software installation: apt‑get, yum.
Display line numbers with cat -n.
2 Useful Expressions
Repeat the previous command with !!, retrieve the last argument with !$, generate numeric sequences with {a..b}, and use brace expansion like touch /tmp/{foo,bar,baz}.
Shell script parameters: $0 (script name), $# (argument count), $? (last exit status), $$ (current shell PID), $* (all arguments).
3 Everyday Commands
Search command history with Ctrl‑R. Use Ctrl‑W, Ctrl‑U, Alt‑BackSpace for word and line deletion in Bash.
Return to the previous directory with cd -. xargs is powerful; test with xargs echo. Example:
find . -name "*.py" | xargs grep some_function
cat hosts | xargs -l {} ssh root@{} hostname parallelenables parallel execution across multiple nodes.
Process tree view: pstree -p. Manage processes with pgrep, pkill, and send signals such as kill -STOP pid.
Run jobs persistently with nohup, disown, screen, or tmux.
Inspect listening ports using lsof or netstat -lntp. Debug Bash scripts with set -x (trace) and set -e (exit on error).
Use a semicolon to start a subshell: (cd /some/dir; other‑command).
Parameter expansion examples: ${name:?error message} (require variable), ${var%suffix}, ${var#prefix}.
Input/output redirection: some_command > logfile 2>&1.
View an ASCII table with man ascii.
Preserve remote SSH sessions with screen or dtach.
Download web pages using curl, curl -l, or wget. Convert HTML to text with lynx -dump -stdin.
Process XML with xmlstarlet. Create SSH tunnels with ssh -L or ssh -D.
Optimize SSH connections by adding to ~/.ssh/config:
TCPKeepAlive=yes
ServerAliveInterval=15
ServerAliveCountMax=6
StrictHostKeyChecking=no
Compression=yes
ForwardAgent=yesComment out a partially typed command with Alt‑# to prepend #.
Schedule tasks with cron. Quickly terminate noisy output with Ctrl‑S followed by Ctrl‑C.
4 Data Processing
Sorting and deduplication: sort, uniq, uniq -u, uniq -d. Text manipulation tools: cut, paste, join. Perform set operations with sort / uniq pipelines, e.g.:
cat a b | sort | uniq > c # union
cat a b | sort | uniq -d > c # intersect
cat a b | sort | uniq -u > c # differenceSet locale to C for faster sorting: export LC_ALL=C.
Aggregate column data with awk: awk '{ x += $3 } END { print x }' Randomize lines with shuf. Control sort fields with -t, -k, -s options, e.g.: cat INPUT_FILE | sort -k1,1 | sort -s -k2,2 Insert a literal tab in Bash using Ctrl‑V or $'\t'.
Binary file utilities: hd, bvi, strings, grep. Convert encodings with iconv or uconv. Split files with split or csplit.
5 System Debugging
Monitor resources with iostat, netstat, top, atop, htop, dstat. Check memory with free or vmstat (cached memory shown).
Generate Java stack traces with kill -3. Diagnose network issues using mtr or traceroute, and bandwidth usage with iftop or nethogs.
Benchmark web servers with ab or siege. Advanced network debugging with wireshark or tshark.
Trace system calls with strace or ltrace (use -c for profiling, -p to attach to a PID). Inspect shared libraries via ldd. Debug programs with gdb and explore /proc (e.g., /proc/cpuinfo, /proc/$$/fd).
Review historical system performance with sar. For deep performance analysis, use stap or perf. Check kernel messages with dmesg.
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.
