The Debian command line is a powerful tool for developers, system administrators, and Linux enthusiasts alike. However, navigating it efficiently requires some know-how. Here are some command-line shortcuts and tips to help you save time and boost productivity.
1. Use Autocomplete (Tab)
One of the most useful features of the Debian command line is autocomplete. Pressing Tab
will:
- Complete a partially typed command or file name.
- List all possible completions if there’s ambiguity.
Example:
This will either auto-complete /etc/apache2/
or display options starting with ap
.
2. Navigate Command History (Arrow Keys)
The Debian shell remembers your previous commands. Use:
↑
and↓
to navigate through your command history.Ctrl + R
to search through past commands interactively.
Example:
3. Clear the Screen Quickly
To clear the cluttered terminal screen, use:
4. Cancel Running Commands
If you accidentally start a process you don’t need or want to interrupt, press:
5. Reuse Last Command Arguments
Sometimes you need to repeat a command with a slight variation. Instead of retyping arguments, use:
!$
: Refers to the last argument of the previous command.
Example:
6. Run the Last Command
To rerun the last command, simply type:
Or:
This is especially useful when you forgot to prepend sudo
.
7. Jump to the Beginning or End of a Line
When editing a command:
Ctrl + A
: Moves the cursor to the beginning of the line.Ctrl + E
: Moves the cursor to the end of the line.
8. Delete Entire Line
To quickly delete the entire line of a command:
9. Delete Word by Word
To delete one word at a time:
- Backward:
Ctrl + W
- Forward:
Ctrl + K
10. Use Aliases
Save time by creating aliases for commonly used commands. Edit your ~/.bashrc
file and add lines like:
Reload the file:
11. Switch Between Virtual Consoles
Debian supports multiple virtual consoles. You can switch between them with:
12. Background and Foreground Processes
Run a command in the background:
Bring it back to the foreground:
13. Use watch
to Monitor Output
The watch
command repeatedly runs another command at intervals:
This refreshes the output every 5 seconds.
14. Quick Directory Navigation
Return to the previous directory:
15. Search Through Files
Use grep
to search for text within files:
Add -r
to search recursively in directories:
16. Use tmux
or screen
For long-running tasks, use terminal multiplexers like tmux
or screen
to keep sessions alive:
Detach and reattach sessions as needed:
17. Check System Information
Use the following commands to quickly check system info:
- CPU info:
lscpu
- Disk usage:
df -h
- Memory usage:
free -m
18. Edit Commands with a Text Editor
To edit a long or complex command in your default editor:
19. Use xargs
for Parallel Processing
Pass output from one command to another:
20. Combine Commands
Chain commands for efficiency:
- Run sequentially:
command1 && command2
- Run regardless of success:
command1 ; command2
- Run only if the first fails:
command1 || command2
Mastering these shortcuts will make your Debian command-line experience much smoother and more efficient. Start using them today, and you’ll find yourself navigating and managing your system like a pro!
What are your favorite shortcuts? Share them in the comments below!
Debian Command Line Shortcuts (F.A.Q)
How can I autocomplete commands or file names?
Press the Tab
key while typing a command or file path. If multiple options are available, pressing Tab
twice lists all possibilities.
What should I do if a command freezes?
Use Ctrl + C
to cancel or stop the running command. If it’s still stuck, use kill
to terminate the process.
How can I repeat the last command with sudo?
Use sudo !!
. It re-executes the last command with elevated privileges.