Master the Linux Command Line: Essential Bash Tips and Tricks
This comprehensive guide presents essential Bash and command‑line techniques for Linux, macOS, and Windows, covering basic navigation, file manipulation, process management, networking, one‑liners, obscure utilities, and platform‑specific tips, along with practical code snippets and references to further resources.
Introduction
This guide collects a wide range of command‑line techniques for Bash and other shells, useful for developers and system administrators on Linux, macOS and Windows.
Basics
Learn to read manual pages with man and explore built‑in commands with help.
Navigate the filesystem using cd, ls, pwd and shortcuts like cd -.
Use redirection operators >, <, >> and pipelines | to combine commands.
Manage background jobs with &, jobs, bg, fg, kill.
Daily Usage
Command history navigation with Ctrl‑r and shortcuts like Ctrl‑w , Ctrl‑u , Alt‑b , Alt‑f .
Switch between vi and emacs key bindings using set -o vi or set -o emacs.
Edit long commands with Ctrl‑x Ctrl‑e after setting EDITOR=vim.
Reuse previous arguments with !$ and !!.
File and Data Processing
Search files with find, locate, and grep / ag.
Manipulate text using sed, awk, cut, paste, sort, uniq, tr.
Handle archives and compressed files with tar, gzip, bzip2, zcat, zgrep.
Convert formats with pandoc, iconv, jq, shyaml, csvkit.
Create, rename, and delete files safely using touch, mv, rm, chmod, chattr.
System Debugging
Monitor system resources with top, htop, iostat, free, vmstat, glances.
Inspect network activity with netstat, ss, iftop, nethogs, mtr, wireshark / tshark.
Trace program execution with strace, ltrace, gdb, perf, systemtap.
Examine kernel and process information via /proc filesystem.
One‑liners
Set operations on sorted files: sort a b | uniq -c > c.
Count column values with awk '{x+=$3} END{print x}' file.
Find the most frequent lines: sort file | uniq -c | sort -rn.
Obscure but Useful Commands
expr, m4, yes, cal, env, printenv, look, fold, column, nl, seq, bc, factor, gpg, tee, timeout, lockfile, logrotate, watch, when‑changed, tac, shuf, comm, strings, tr, iconv, split, csplit, sponge, units, apg, xz, ldd, nm, ab, strace, mtr, cssh, rsync, wireshark, ngrep, host, dig, lsof, dstat, glances, iostat, mpstat, vmstat, htop, last, w, sar, ifconfig, ss, dmesg, sysctl, hdparm, lsblk, lshw, lscpu, lspci, lsusb, dmidecode, lsmod, modinfo, fortune, ddate, sl.
OS X Specific Tips
Install Unix tools with Homebrew ( brew) or MacPorts ( port).
Copy/paste using pbcopy and pbpaste.
Open files with open or open -a.
Search with Spotlight via mdfind and view metadata with mdls.
Be aware of BSD‑style command differences; use GNU versions when needed.
Check OS version with sw_vers.
Windows Specific Tips
Manage the system with wmic.
Network diagnostics with ping, ipconfig, tracert, netstat.
Run commands via Rundll32.
Cygwin Tips
Install additional Unix packages with Cygwin’s setup.
Use mintty as the terminal emulator.
Access Windows clipboard via /dev/clipboard.
Open Windows files with cygstart.
Query the registry with regtool.
Convert paths using cygpath.
Use wmic for Windows management from Cygwin.
Further Resources
awesome‑shell – curated list of command‑line tools.
awesome‑osx‑command‑line – deeper OS X guide.
Strict mode – write safer Bash scripts.
shellcheck – static analysis for shell scripts.
Filenames and Pathnames in Shell – handling edge cases.
Data Science at the Command Line – command‑line tools for data work.
Source: GitHub – https://github.com/jlevy/the-art-of-command-line/blob/master/README-zh.md
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.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
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.
