20 Essential Linux Terminal Tricks to Supercharge Your Productivity
This article compiles a set of practical Linux command‑line shortcuts—from tab completion and directory navigation to history search and log monitoring—that help both beginners and seasoned users work faster, avoid common pitfalls, and boost overall terminal productivity.
This article presents a collection of practical Linux terminal tricks that can save time, avoid common pitfalls, and boost productivity for both beginners and experienced users.
1. Use Tab for Auto‑completion
Press Tab while typing a command to let the shell suggest completions that start with the entered string, e.g., typing
cp land pressing Tab completes
linuxidc.txt.
2. Switch Back to the Previous Directory
Enter
cd -to return to the last working directory without re‑typing the full path. The command works only after you have changed directories at least once.
3. Jump Directly to Your Home Directory
Use
cd ~or simply
cdto move to the home directory from anywhere, saving a couple of keystrokes on modern distributions.
4. List Directory Contents Quickly
Instead of
ls -l, many distributions support the
llalias, which produces a long listing with the same information.
5. Run Multiple Commands on One Line
Separate commands with a semicolon (
;) to execute them sequentially without waiting for each to finish, e.g.,
command_1; command_2; command_3.
6. Execute the Next Command Only on Success
Use the
&&operator so the second command runs only if the first succeeds, for example
sudo apt update && sudo apt upgrade.
7. Search Your Command History
Press
Ctrl+Rand type a keyword to perform a reverse search through the Bash history; repeat
Ctrl+Rfor additional matches, and exit with
Ctrl+C.
8. Unfreeze a Stuck Terminal (Ctrl+S / Ctrl+Q)
On many Unix‑like systems,
Ctrl+Spauses output; resume with
Ctrl+Q.
9. Jump to Line Start or End
Use
Ctrl+Ato move to the beginning of the line and
Ctrl+Eto move to the end, which is often faster than the Home/End keys on laptops.
10. Follow Log Files in Real Time
Run
tail -F <logfile>(equivalent to
--follow=name --retry) to keep tracking a log file even after it is rotated or recreated.
11. View Compressed Logs Without Decompressing
Use the
zcat(or
zless,
zgrep) family to read gzip‑compressed logs directly, e.g.,
zcat linuxidc_log.zip | more.
12. Browse Files with less
Prefer
less -N <file>over
catfor large files; it supports paging, searching, line numbers, and can be exited with
q.
13. Reuse the Last Argument of the Previous Command
Typing
!$expands to the final argument of the previous command, useful for chaining operations without re‑typing.
14. Repeat the Previous Command Quickly
Enter
!!to execute the entire previous command; prepend
sudo(e.g.,
sudo !!) to rerun it with root privileges.
15. Create Aliases to Fix Typos
Define an alias such as
alias gerp=grepin
~/.bashrcto correct frequent misspellings.
16. Copy and Paste in the Terminal
Select text and right‑click to paste (common in PuTTY).
Select text and click the middle mouse button.
Use
Ctrl+Shift+Cto copy and
Ctrl+Shift+Vto paste in most modern terminals.
17. Abort a Running Command
Press
Ctrl+Cto terminate the current foreground process.
18. Empty a File Without Deleting It
Run
> filenameto truncate the file to zero length.
19. Search for Files Containing Specific Text
Use
grep -Pri "search_string" /pathto recursively find files that contain the given pattern.
20. Use Built‑in Help
Most commands provide a help page (e.g.,
bc -help) that explains usage and options.
These tips work on almost any Linux distribution and shell without installing additional tools.
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.