Common Linux Command-Line Shortcuts
As a Linux technical expert and mentor, I'm happy to share some of the most common and useful command-line shortcuts that can greatly improve your productivity and efficiency when working in the Linux terminal.
Navigation Shortcuts
-
Moving the Cursor: Use the arrow keys (up, down, left, right) to move the cursor within the current command line. You can also use the following shortcuts:
Ctrl + A
: Move the cursor to the beginning of the line.Ctrl + E
: Move the cursor to the end of the line.Ctrl + B
: Move the cursor one character backward.Ctrl + F
: Move the cursor one character forward.
-
History Navigation: Use the following shortcuts to navigate through your command history:
Up Arrow
: Cycle through the previous commands.Down Arrow
: Cycle through the next commands.Ctrl + R
: Perform a reverse search through your command history.
-
Tab Completion: Press the
Tab
key to automatically complete partially typed commands, file names, or directory names. This can save you a lot of time and typing.
Editing Shortcuts
-
Deleting Text: Use the following shortcuts to delete text:
Ctrl + K
: Delete the text from the cursor to the end of the line.Ctrl + U
: Delete the text from the cursor to the beginning of the line.Ctrl + W
: Delete the word before the cursor.
-
Copying and Pasting: Use the following shortcuts to copy and paste text:
Ctrl + Shift + C
: Copy the selected text.Ctrl + Shift + V
: Paste the copied text.
-
Clearing the Screen: Use the
clear
command to clear the terminal screen.
Process Control Shortcuts
-
Stopping a Process: Use the following shortcuts to stop a running process:
Ctrl + C
: Terminate the current foreground process.Ctrl + Z
: Suspend the current foreground process.
-
Resuming a Suspended Process: Use the
fg
command to resume a suspended process in the foreground, orbg
to resume it in the background.
Miscellaneous Shortcuts
- Autocomplete for Commands: Press
Tab
twice to see a list of available commands that match the partially typed text. - Searching Through Man Pages: Press
/
and then type your search query to search through the man pages. - Exiting the Terminal: Use the
exit
command or pressCtrl + D
to exit the current terminal session.
Here's a Mermaid diagram that summarizes the key command-line shortcuts:
Remember, mastering these command-line shortcuts can significantly boost your productivity and make your Linux workflow more efficient. Feel free to experiment with them and incorporate them into your daily Linux usage.