Linux Terminal Productivity Tips
Introduction
Working in the Terminal is a completely different experience compared to GUI environments like Windows. There’s no drag and drop, no mouse pointer to select files or folders — only a command line on a black screen.
However, this simplicity offers powerful and efficient control over the system. Using the Terminal saves time and handles complex tasks more effectively. This article shares practical tips to help you work more easily and efficiently with the Terminal.
Keyboard Shortcuts
In both Terminal and GUI environments, using keyboard shortcuts significantly boosts your productivity. The shortcuts below are some of the most useful in Terminal:
Ctrl + Z (pause/suspend)
This shortcut suspends the currently running process (without terminating it). It is especially helpful when combined with the bg
command to continue running in the background. Works well with commands like mysqldump
, mysqlcheck
, etc.
Ctrl + L (clear screen)
Clears the current Terminal view by scrolling the screen up. Unlike the clear
command, this shortcut has several advantages:
- Faster: No need to type
clear
and press Enter. - Preserves history: Unlike
clear
, it doesn’t affect command history. - Doesn’t erase the current command: Your current input remains intact.
- Works across many CLI environments.
!! + Enter
The !!
shortcut reruns the last executed command. It’s especially useful when you forget to use sudo
:
Instead of using the arrow keys and editing manually, just type sudo !!
.
Other Useful Shortcuts
Shortcut | Description |
Ctrl + A | Move cursor to the beginning of the line. |
Ctrl + E | Move cursor to the end of the line. |
Alt + F | Move cursor forward one word. |
Alt + B | Move cursor backward one word. |
Ctrl + F | Move cursor forward one character. |
Ctrl + B | Move cursor backward one character. |
Ctrl + U | Cut everything before the cursor. |
Ctrl + K | Cut everything after the cursor. |
Ctrl + W | Cut the word before the cursor. |
Ctrl + Y | Paste the last cut content. |
Ctrl + R | Search command history. |
Useful Commands
Mastering Linux means being familiar with its commands. Let’s explore a few essential and commonly used commands:
grep Command
grep [options] [patterns] [files]
The grep
command searches for matching text within files or command output (stdout).
Search in a file
grep 'about-us' /var/log/nginx/access.log
Searches for lines containing ‘about-us’ in the access.log file.
Wildcard search
grep 'about-us' /var/log/nginx/access-*.log
Searches for ‘about-us’ across all access-*.log files.
Search in command output (STDOUT)
ps -aux | grep php
Filters the process list for running PHP processes.
Show line numbers
grep -n 'about-us' /var/log/nginx/access.log
Displays matching lines along with their line numbers.
Count matches
grep -c 'google' /var/log/nginx/access.log
Counts the number of matches for ‘google’.
tee Command
Sometimes, you may want to view output on screen and also save it to a file for later analysis.
Output and save to file
find . -name '*.xml' | tee ./files.txt
Save to multiple files
find . -name '*.xml' | tee ./main.txt ./backup.txt
Pipe (|)
Pipes are not commands but a way to redirect output (STDOUT) from one command as input (STDIN) to another.
ps -aux | grep php
Instead of displaying output directly, the pipe sends it to grep
for filtering PHP processes.
Benefits of pipe:
- Simplifies data processing (no need for intermediate files).
- Reduces system resources.
- Saves time.
Conclusion
Mastering the Linux Terminal is an essential skill for any developer. It boosts speed, accuracy, and efficiency while enabling advanced customization and automation.
This article shared useful shortcuts, commands, and practical insights to help you work more effectively in Terminal.
![]() | Vũ Khắc Nguyễn Developer |