Practical Shell Commands and One-Liners Developers Actually Use

July 27, 2025

While the internet is full of obscure shell commands, the most valuable ones are often those that solve common, everyday problems. A recent discussion among developers and system administrators revealed a treasure trove of practical one-liners, aliases, and workflow enhancements that can significantly boost productivity on the command line.

Everyday Convenience and Navigation

Some of the most frequently used commands are the simplest. Many users rely on aliases to shorten long commands or bundle a few together for quick context checks.

  • Aliases for Clarity: A clever alias, alias huh='pwd; whoami', helps quickly answer the questions "Where am I, and who am I?"—especially useful when managing multiple servers. Standard aliases like alias ll='ls -lrt' and alias untar='tar -zxvf' are also popular time-savers.
  • Mastering History and Navigation: Instead of retyping commands, power users leverage shell history. ctrl+r provides an incremental search through your command history, and its power is amplified when combined with fzf for a fuzzy, interactive search experience. For directory navigation, cd - is an indispensable command for quickly switching back to the previous directory. A neat trick for temporary tasks in another directory is to start a subshell (by typing bash), do your work, and then simply exit (or ctrl+d) to return to your original location and context.

Working with Files and Processes

Handling files and processes efficiently is a core command-line skill. These techniques and tools make it easier.

  • Processing Large Files: When a command like grep is running on a huge file, it's hard to know its progress. Piping the file through pv (Pipe Viewer) first (pv huge.log | grep 'error') provides a progress bar, ETA, and throughput data.
  • Bulk Operations: The find command is incredibly powerful, especially with its -exec option. This allows you to run any command on a set of files matching your criteria. A safe way to use it is to run the find command without -exec first to ensure you've selected the correct files.
  • Finding Processes: While ps aux | grep [p]rocess is common, a cleaner and more direct method is to use pgrep -fl <name>, which is designed specifically for finding processes by name.
  • Comparing Files: For comparing structured files like JSON, combining jq for formatting/pretty-printing with a diff tool is highly effective: vimdiff <(jq < file1.json) <(jq < file2.json).

Advanced System Administration Chains

For sysadmins, chaining multiple commands together is essential for monitoring and maintenance. Here are a few examples of powerful, real-world one-liners:

  • MySQL Optimization: Find and optimize all MySQL tables larger than 1GB: bash for tbl in $(find /var/lib/mysql/ -name *.ibd -size +1G); do optimize table ...; done
  • Log Analysis: Find the top 50 IP addresses hitting an Nginx server: bash tail -100000 /var/log/nginx/access.log | awk '{print $1}' | sort | uniq -c | sort -n | tail -50
  • Memory Usage: List the processes using the most swap space: bash for f in /proc/*/status; do awk '/VmSwap|Name/{printf $2 " " $3}END{print ""}' $f; done | awk '{print $2" "$3" "$1}' | sort -n | tail -20

Developer and Workflow Boosters

Several tools and settings can make the development cycle smoother.

  • Searching Code: To find all files in a git repository containing a string, git grep -l <string> is fast and repository-aware. rg -l <string> (using Ripgrep) is a popular, even faster alternative.
  • Logging and Sessions: When running long builds, use tee to both see the output and save it to a file: make 2>&1 | tee build.log. For managing remote sessions and logging everything, tmux and GNU Screen are invaluable. In Screen, CTRL-A + Shift-H toggles logging all output for the current window.

Get the most insightful discussions and trending stories delivered to your inbox, every Wednesday.