In the world of Linux, efficiency is king. One of the fastest ways to boost your productivity and become a true power user is by mastering keyboard shortcuts. Moving your hands from the keyboard to the mouse and back costs precious seconds that add up over time. By keeping your fingers on the keys, you can navigate, edit, and manage your system with lightning speed.
Table of Contents
This guide serves as a comprehensive reference to the most essential keyboard shortcuts for the Linux command line and its most popular applications. We’ll cover everything from the bash
shell and terminal emulators like gnome-terminal
to powerful text editors like emacs
and vi/vim
.
This reference uses the default configurations found in most Linux distributions. While almost all programs allow you to customize these shortcuts, mastering the defaults is the perfect place to start.
bash
The Bourne Again Shell (bash
) is the command-line interface for most Linux users. These shortcuts, which are part of the readline
library, are indispensable for quickly writing and editing commands.
Keyboard Shortcut | Function |
---|---|
Ctrl + A | Moves the cursor to the beginning of the line. |
Ctrl + E | Moves the cursor to the end of the line. |
Ctrl + C | Cancels the current command. |
Ctrl + K | Deletes the rest of the line from the cursor. |
Ctrl + Y | Reinserts (yanks) the most recently deleted text. |
Ctrl + Z | Suspends the current command (resume with fg or bg ). |
Tab | Completes file and command names. |
Arrow Up / Arrow Down | Scrolls through the command history. |
emacs
emacs
is one of the most feature-rich and extensible text editors available. Its entire interface is built around keyboard commands. In emacs
documentation, C
stands for Ctrl
, and M
stands for Meta, which is usually the Alt
key on modern keyboards. M-x
can be executed by pressing Alt + X
or by pressing Esc
then X
.
Basic Commands
Keyboard Shortcut | Function |
---|---|
Ctrl + X, Ctrl + F | Loads a new file (find-file). |
Ctrl + X, Ctrl + S | Saves the current file. |
Ctrl + X, Ctrl + W | Saves the file under a new name. |
Ctrl + X, Ctrl + C | Exits emacs (prompts to save). |
Ctrl + G | Cancels the current command. |
Ctrl + X, U | Undoes the last change (undo). |
Cursor Movement
Keyboard Shortcut | Function |
---|---|
Alt + F / Alt + B | Moves one word forward or backward. |
Ctrl + A / Ctrl + E | Moves to the beginning or end of the line. |
Alt + < / Alt + > | Moves to the beginning or end of the text. |
Alt + G n Enter | Moves the cursor to line number ‘n’. |
Selecting, Deleting, and Reinserting Text
Keyboard Shortcut | Function |
---|---|
Ctrl + Space | Sets an invisible marker point (the “mark”). |
Ctrl + W | Deletes (cuts) the text between the mark and the cursor. |
Ctrl + Y | Inserts (pastes) the last deleted text. |
Ctrl + X, Ctrl + X | Swaps the cursor position and the mark. |
Alt + D | Deletes the next word. |
Alt + Backspace | Deletes the previous word. |
Ctrl + K | Deletes from the cursor to the end of the line. |
Search and Replace
Keyboard Shortcut | Function |
---|---|
Ctrl + S | Incremental search forward. |
Ctrl + R | Incremental search backward. |
Alt + % | Search and replace (query-replace). |
Alt + X query-replace-r | Search and replace with regular expressions. |
gnome-terminal
The default terminal emulator for the GNOME desktop environment. These shortcuts help manage windows, tabs, and text within the terminal itself.
Keyboard Shortcut | Function |
---|---|
Shift + Ctrl + C | Copies selected text to the clipboard. |
Shift + Ctrl + V | Pastes text from the clipboard. |
Shift + Ctrl + F | Searches for text in the terminal output. |
Shift + Ctrl + N | Opens a new terminal window. |
Shift + Ctrl + T | Opens a new terminal tab. |
Shift + Ctrl + W | Closes the current tab. |
Shift + Ctrl + Q | Closes the terminal window. |
Shift + Ctrl + PgUp/PgDown | Switches to the previous/next tab. |
Shift + Ctrl + + | Enlarges the font size. |
Shift + Ctrl + - | Reduces the font size. |
F11 | Toggles full-screen mode. |
grub
The GRand Unified Bootloader (GRUB) is what loads Linux when you start your computer. These keys allow you to edit boot parameters before the system starts.
Keyboard Shortcut | Function |
---|---|
E | Edits the selected boot menu item. |
C | Opens the GRUB command-line interface. |
Ctrl + X or F10 | Boots the selected or edited menu item. |
Esc | Exits the editor or command line, returning to the menu. |
less
The less
command is a pager used to view text files one screen at a time. It’s more powerful than its predecessor, more
.
Keyboard Shortcut | Function |
---|---|
Arrow Keys | Scrolls the text up or down line by line. |
Spacebar or f | Scrolls forward one page. |
b | Scrolls backward one page. |
G | Jumps to the end of the text. |
g | Jumps to the beginning of the text. |
/pattern | Searches forward for ‘pattern’. |
?pattern | Searches backward for ‘pattern’. |
n | Repeats the last search in the same direction. |
N | Repeats the last search in the opposite direction. |
V | Starts the default system editor ($EDITOR ). |
H | Displays a help screen with more commands. |
Q | Quits less. |
vi / vim
The vi
editor (and its modern incarnation, vim
) is a ubiquitous and powerful text editor with a steep learning curve. Its main paradigm is the separation of modes. You start in Normal Mode, where keys execute commands. To type text, you must enter Insert Mode.
Basic Commands & Modes
Keystroke | Mode / Function |
---|---|
i | Enters Insert Mode at the cursor. |
a | Enters Insert Mode after the cursor. |
Esc | Returns to Normal Mode from any other mode. |
: | Enters Command-Line Mode from Normal Mode. |
dd | (Normal Mode) Deletes the current line. |
dw | (Normal Mode) Deletes one word. |
p | (Normal Mode) Pastes the last deleted text after the cursor. |
u | (Normal Mode) Undoes the last change. |
Ctrl + r | (Normal Mode) Redoes the last undo. |
:w | (Command-Line Mode) Saves (writes) the file. |
:q | (Command-Line Mode) Quits the editor. |
:wq | (Command-Line Mode) Saves and quits. |
:q! | (Command-Line Mode) Quits without saving changes. |
Searching and Replacing
These commands are run from Normal Mode.
Command | Function |
---|---|
/pattern | Searches forward for ‘pattern’. |
?pattern | Searches backward for ‘pattern’. |
n | Repeats the search in the same direction. |
N | Repeats the search in the opposite direction. |
:%s/old/new/g | Replaces all ‘old’ with ‘new’ in the file. |
:%s/old/new/gc | Replaces all, but confirms each replacement. |
More Topics
- How to Get Started Auditing Kubernetes Security with Kali
- How to Use Kali Linux Legally and Ethically: A Guide for Pentesters
- How to Manage Sudo Privileges in Kali for Better Team Security
- How to Create a Rogue Access Point in Kali for Security Audits
- How to Perform a Live Forensic Disk Image Acquisition with Kali
- How to Evade Basic AV with Payload Obfuscation
- How to Establish Persistence on a Linux System