20 Essential Linux Terminal Tricks to Supercharge Your Productivity
Discover a collection of 20 practical Linux terminal shortcuts—from tab completion and quick directory navigation to command chaining, reverse history search, and efficient log handling—that can dramatically reduce typing, prevent errors, and boost your workflow efficiency across any distribution or shell environment.
Here are some useful Linux commands, terminal tricks, and shortcuts that can save a lot of time when using the Linux command line.
1. Use Tab for Auto‑completion
Press the Tab key while typing a command to automatically complete file names or commands that start with the typed prefix.
Tab can also be used to complete commands after they are partially typed.
2. Switch Back to the Previous Directory
Use cd - to return to the last working directory without re‑typing the full path.
cd -If no previous directory exists, an error like bash: cd: OLDPWD not set will be shown.
3. Return to the Home Directory
Use cd ~ or simply cd to jump to the home directory from anywhere.
cd ~ cd4. List Directory Contents Quickly
Instead of ls -l, many users prefer the ll alias, which provides a detailed listing.
ll5. Run Multiple Commands on One Line
Separate commands with a semicolon ; to execute them sequentially without waiting for each to finish.
command_1; command_2; command_36. Run Commands Conditionally (Only on Success)
Use the double‑ampersand && to run the next command only if the previous one succeeds. command_1 && command_2 Example:
sudo apt update && sudo apt upgrade7. Search Your Command History
Press Ctrl + r and type a keyword to perform a reverse search through previously entered commands.
ctrl + r keyword8. Unfreeze a Frozen Terminal
On many Unix‑like systems, Ctrl + S pauses output. Resume with Ctrl + Q.
9. Jump to Line Start or End
Use Ctrl + A to move to the beginning of the line and Ctrl + E to move to the end.
10. Follow Log Files in Real Time
Use tail -F <logfile> to continuously monitor a log file, even if it is rotated or recreated.
tail -F linuxidc_log11. Read Compressed Logs Without Decompressing
Use the z suite (e.g., zcat, zless, zgrep) to view gzip‑compressed files directly.
zcat linuxidc_log.zip | more12. Use less to View Files
less -N <file>provides paging, searching, line numbers, and does not load the entire file into memory.
less -N linuxidc.txt13. Reuse the Last Argument of the Previous Command
Type !$ to insert the final argument from the preceding command.
14. Re‑execute the Entire Previous Command
Use !! to repeat the last command, useful for quickly adding sudo.
15. Create Aliases to Fix Typos
Define an alias such as alias gerp=grep to correct common misspellings.
alias gerp=grep16. Copy and Paste in the Terminal
Typical shortcuts: select text and right‑click to paste (PuTTY, Windows SSH clients), or use Ctrl + Shift + C / Ctrl + Shift + V for copy/paste in many terminals.
17. Terminate a Running Command
Press Ctrl + C to stop the currently executing command or process.
18. Empty a File Without Deleting It
> filename19. Find Files Containing Specific Text
grep -Pri "search_string" /path/to/searchFor more advanced file searching, see the find command documentation.
20. Use the Built‑in Help for Any Command
Most commands provide a help page (e.g., bc -help) that describes usage and options. bc -help These Linux terminal tricks work on almost all distributions and shells without installing additional tools.
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.
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
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.
