Master Your Workflow: The Ultimate Guide to Linux Keyboard Shortcuts

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.

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 ShortcutFunction
Ctrl + AMoves the cursor to the beginning of the line.
Ctrl + EMoves the cursor to the end of the line.
Ctrl + CCancels the current command.
Ctrl + KDeletes the rest of the line from the cursor.
Ctrl + YReinserts (yanks) the most recently deleted text.
Ctrl + ZSuspends the current command (resume with fg or bg).
TabCompletes file and command names.
Arrow Up / Arrow DownScrolls 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 ShortcutFunction
Ctrl + X, Ctrl + FLoads a new file (find-file).
Ctrl + X, Ctrl + SSaves the current file.
Ctrl + X, Ctrl + WSaves the file under a new name.
Ctrl + X, Ctrl + CExits emacs (prompts to save).
Ctrl + GCancels the current command.
Ctrl + X, UUndoes the last change (undo).

Cursor Movement

Keyboard ShortcutFunction
Alt + F / Alt + BMoves one word forward or backward.
Ctrl + A / Ctrl + EMoves to the beginning or end of the line.
Alt + < / Alt + >Moves to the beginning or end of the text.
Alt + G n EnterMoves the cursor to line number ‘n’.

Selecting, Deleting, and Reinserting Text

Keyboard ShortcutFunction
Ctrl + SpaceSets an invisible marker point (the “mark”).
Ctrl + WDeletes (cuts) the text between the mark and the cursor.
Ctrl + YInserts (pastes) the last deleted text.
Ctrl + X, Ctrl + XSwaps the cursor position and the mark.
Alt + DDeletes the next word.
Alt + BackspaceDeletes the previous word.
Ctrl + KDeletes from the cursor to the end of the line.

Search and Replace

Keyboard ShortcutFunction
Ctrl + SIncremental search forward.
Ctrl + RIncremental search backward.
Alt + %Search and replace (query-replace).
Alt + X query-replace-rSearch 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 ShortcutFunction
Shift + Ctrl + CCopies selected text to the clipboard.
Shift + Ctrl + VPastes text from the clipboard.
Shift + Ctrl + FSearches for text in the terminal output.
Shift + Ctrl + NOpens a new terminal window.
Shift + Ctrl + TOpens a new terminal tab.
Shift + Ctrl + WCloses the current tab.
Shift + Ctrl + QCloses the terminal window.
Shift + Ctrl + PgUp/PgDownSwitches to the previous/next tab.
Shift + Ctrl + +Enlarges the font size.
Shift + Ctrl + -Reduces the font size.
F11Toggles 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 ShortcutFunction
EEdits the selected boot menu item.
COpens the GRUB command-line interface.
Ctrl + X or F10Boots the selected or edited menu item.
EscExits 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 ShortcutFunction
Arrow KeysScrolls the text up or down line by line.
Spacebar or fScrolls forward one page.
bScrolls backward one page.
GJumps to the end of the text.
gJumps to the beginning of the text.
/patternSearches forward for ‘pattern’.
?patternSearches backward for ‘pattern’.
nRepeats the last search in the same direction.
NRepeats the last search in the opposite direction.
VStarts the default system editor ($EDITOR).
HDisplays a help screen with more commands.
QQuits 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

KeystrokeMode / Function
iEnters Insert Mode at the cursor.
aEnters Insert Mode after the cursor.
EscReturns 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.

CommandFunction
/patternSearches forward for ‘pattern’.
?patternSearches backward for ‘pattern’.
nRepeats the search in the same direction.
NRepeats the search in the opposite direction.
:%s/old/new/gReplaces all ‘old’ with ‘new’ in the file.
:%s/old/new/gcReplaces all, but confirms each replacement.

More Topics

Hello! I'm a gaming enthusiast, a history buff, a cinema lover, connected to the news, and I enjoy exploring different lifestyles. I'm Yaman Şener/trioner.com, a web content creator who brings all these interests together to offer readers in-depth analyses, informative content, and inspiring perspectives. I'm here to accompany you through the vast spectrum of the digital world.

Leave a Reply

Your email address will not be published. Required fields are marked *