Linux

Master Linux Command Line Keyboard Shortcuts to Speed Up Your Work

This guide covers essential and advanced keyboard shortcuts for bash and zsh in Linux, helping you navigate faster, edit commands efficiently, and manage processes in the terminal.

Updated at February 16, 2026
10-15 minutes
Easy
FixPedia Team
Применимо к:Linux with bash 4.0+ or zsh 5.0+Ubuntu 20.04+, Fedora 35+, Debian 10+

Introduction / Why This Is Needed

Working in the Linux command line is a powerful tool for administration, development, and automation. However, constantly entering commands with the mouse or moving around with arrow keys can slow down your workflow. Keyboard shortcuts (hotkeys) allow for fast navigation, command editing, and process management, saving precious seconds. After mastering these combinations, you'll notice a significant productivity boost, especially during long terminal sessions. In this guide, we'll cover the most useful shortcuts for bash and zsh—the most popular Linux shells.

Requirements / Preparation

Before you begin, make sure you have:

  1. Access to a Linux terminal — any graphical terminal (gnome-terminal, konsole, xterm) or virtual console (Ctrl+Alt+F1-F6).
  2. An installed shell — bash (default in most distributions) or zsh. You can check your current shell with:
    echo $SHELL
    
  3. Basic command-line knowledge — the ability to enter and run simple commands.

💡 Tip: If you're a beginner, start with bash, as its keyboard shortcuts are the most universal. Zsh offers additional features, but the basic combinations are compatible.

Essential Keyboard Shortcuts for Navigation

These combinations will help you move quickly within the input line without using the mouse or arrow keys.

Character and Word Navigation

  • Ctrl+A — Move to the beginning of the command line.
  • Ctrl+E — Move to the end of the command line.
  • Ctrl+B — Move backward one character (like the ← arrow).
  • Ctrl+F — Move forward one character (like the → arrow).
  • Alt+B — Move backward one word (delimiters: space, hyphen, slash).
  • Alt+F — Move forward one word.

⚠️ Important: On some systems, the Alt key may not work in the terminal by default. In this case, use Esc before pressing B or F (e.g., press Esc then B to move back a word).

Quick Position Switching

  • Ctrl+XX — Toggle between the beginning of the line and the current cursor position (works in bash and zsh when the set -o emacs option is enabled).

Example: You typed a long command but need to fix the beginning. Press Ctrl+A, make edits, then Ctrl+XX — the cursor will return to where you originally stopped.

Shortcuts for Command Editing

These combinations speed up typo correction and command modification.

Text Deletion

  • Ctrl+U — Delete everything from the cursor to the beginning of the line.
  • Ctrl+K — Delete everything from the cursor to the end of the line.
  • Ctrl+W — Delete the word before the cursor (from the current position to the previous delimiter).
  • Alt+D — Delete the word after the cursor (from the current position to the next delimiter).
  • Ctrl+D — Delete the character under the cursor (like the Delete key).

Pasting and Undoing

  • Ctrl+Y — Paste (yank) the last deleted text (combinations like Ctrl+U, Ctrl+K, Ctrl+W save text to a buffer).
  • Alt+. (period) — Insert the last argument from the previous command. Pressing Alt+. repeatedly cycles through arguments from history.
  • Ctrl+_ (or Ctrl+Shift+-) — Undo the last change (like undo).

Example: You entered cp file1.txt /path/to/destination/. Then you want to copy file2.txt to the same location. Type cp file2.txt and press Alt+. — it will insert /path/to/destination/.

Correcting Typos

  • Alt+T — Swap the two most recent words (useful if you reversed the order).
  • Ctrl+T — Swap the two most recent characters (for correcting transposed letters).

Searching and Working with Command History

The terminal saves the history of all entered commands. These shortcuts let you quickly find and repeat them.

  • Ctrl+R — Start a reverse search through history. Begin typing part of a command, and the terminal will show the first match. Press Ctrl+R again to find earlier matches. Ctrl+G exits the search while keeping the found command in the line.
  • Ctrl+SForward search (may be blocked in some terminals; unlock with stty -ixon).

History Navigation

  • Ctrl+P (or ↑ arrow) — Previous command in history.
  • Ctrl+N (or ↓ arrow) — Next command in history.
  • Ctrl+G — Exit search mode or cancel current input.
  • !! — Execute the last command (handy if you forgot sudo). Example: sudo !!.
  • !$ — Use the last argument of the last command. Example: mv file1.txt /tmp/ then cat !$ will open /tmp/.
  • !^ — Use the first argument of the last command.
  • !-2 — Execute the command entered two steps back in history.

Process Management

When a process is running in the terminal, these shortcuts help you manage it without closing the session.

  • Ctrl+CInterrupt the current process (sends SIGINT). Use if a command is stuck or you need to stop it.
  • Ctrl+ZSuspend the process (sends SIGSTOP) and return to the shell. The process remains in memory.
  • Ctrl+D — Send EOF (end-of-file). If typed on an empty line, it terminates the current shell session (like exit).
  • bg — Resume a suspended process in the background.
  • fg — Resume a suspended process in the foreground (in the current terminal).
  • jobs — List all suspended and background jobs in the current session.

Example: You started sleep 1000 but need to return to the terminal. Press Ctrl+Z, then bg — the process will continue running in the background.

Advanced Configuration and Customization

While the standard shortcuts are sufficient for most tasks, you can customize your own or improve existing ones.

Configuring bash via ~/.inputrc

The ~/.inputrc file controls readline behavior (the library used by bash). Add lines for new shortcuts.

Example: Make Ctrl+Left/Right work for word navigation (by default, they send escape sequences in some terminals).

# ~/.inputrc
"\e[1;5D": backward-word   # Ctrl+Left
"\e[1;5C": forward-word    # Ctrl+Right
"\e[5~": beginning-of-history  # PageUp for history search
"\e[6~": end-of-history        # PageDown

After saving the file, restart the terminal or run bind -f ~/.inputrc.

Configuring zsh via ~/.zshrc

In zsh, shortcuts are managed via bindkey. Add to ~/.zshrc:

# Example: Ctrl+Left/Right for word navigation
bindkey "^[[1;5D" backward-word
bindkey "^[[1;5C" forward-word
# Enable emacs mode (zsh may default to vicmd-mode)
bindkey -e

Reload zsh: source ~/.zshrc.

Creating Macros

You can assign a key to a sequence of commands. For example, in bash via ~/.inputrc:

# Ctrl+T inserts the date in YYYY-MM-DD format
"\C-t": "date +%Y-%m-%d"

In zsh via ~/.zshrc:

bindkey "^T" insert-datetime
insert-datetime() {
  LBUFFER+=$(date +%Y-%m-%d)
}
zle -N insert-datetime

Practical Tips for Memorization

  1. Start small — Learn 5-7 of the most common shortcuts (e.g., Ctrl+A, Ctrl+E, Ctrl+U, Ctrl+K, Ctrl+R). Use them consciously every day.
  2. Create a cheat sheet — Print a table of shortcuts and place it near your monitor. We've prepared a PDF cheat sheet for you — download it here (link will be added in the real article).
  3. Practice outside work hours — Open a terminal and try typing long commands using only shortcuts, without the mouse.
  4. Use Ctrl+P/Ctrl+N instead of arrows — This habit forms quickly.
  5. Don't fear mistakes — If you accidentally delete text, Ctrl+Y will restore it.

Checking Your Results

After studying this guide, you should be able to:

  1. Move quickly along long commands using Ctrl+A/E/B/F.
  2. Correct typos without retyping (e.g., Ctrl+U to delete part of a command).
  3. Find and repeat previous commands via Ctrl+R and !!.
  4. Manage background tasks (Ctrl+Z, bg, fg).
  5. Customize your own shortcuts via config files if needed.

Test yourself: Open a terminal and enter a complex command, for example:

sudo apt update && sudo apt upgrade -y

Now, without using arrows or the mouse:

  • Move to the start of the line (Ctrl+A), delete part (Ctrl+K), paste it back (Ctrl+Y).
  • Find the command sudo apt update via Ctrl+R.
  • Interrupt execution (if it's running) via Ctrl+C.

If everything works — you're on the right track!

Potential Issues

Shortcuts Don't Work in My Terminal

  • Problem: Alt+B or Alt+F do nothing.
    • Solution: Use Esc instead of Alt, then press B or F. Or configure your terminal to send Meta sequences (e.g., in gnome-terminal: Settings → Keys → "Alt sends ESC").
  • Problem: Ctrl+Left/Right don't move by words.
    • Solution: Configure ~/.inputrc or ~/.zshrc as shown above. Ensure the escape sequences match your terminal (check by running cat and pressing the combination).

Conflicts with Applications

  • Problem: In vim or nano, keyboard shortcuts may differ or be intercepted.
    • Solution: In vim, use Ctrl+[ instead of Esc, and for word navigation use W/B in normal mode. In nano, shortcuts are similar to GUI editors (e.g., Ctrl+←). Consider the application context.

Zsh in Vi Mode

  • Problem: By default, zsh may use vi mode (like vim), where shortcuts are different.
    • Solution: Switch to emacs mode (more familiar for bash users) by adding bindkey -e to ~/.zshrc.

Resetting Settings

  • If you break your configuration, delete or rename ~/.inputrc/~/.zshrc and restart the terminal — default settings will be restored.

Different Terminals

  • In graphical terminals (gnome-terminal, konsole), shortcuts usually work out of the box. In the console (Ctrl+Alt+F1), some escape sequences may differ. Test in your environment.

F.A.Q.

How to quickly learn all keyboard shortcuts?
Are there differences in keyboard shortcuts between bash and zsh?
What to do if a shortcut doesn't work in my terminal?
Can I create custom keyboard shortcuts?

Hints

Learn basic navigation shortcuts
Master command editing shortcuts
Practice history search
Learn process management
Customize your shortcuts (optional)
Practice regularly
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community