_____                   _             ___     _________  __
 |_   _|__ _ __ _ __ ___ (_)_ __   __ _| \ \   / / ____\ \/ /
   | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | |\ \ / /|  _|  \  /
   | |  __/ |  | | | | | | | | | | (_| | | \ V / | |___ /  \
   |_|\___|_|  |_| |_| |_|_|_| |_|\__,_|_|  \_/  |_____/_/\_\
basics13 min

Terminal Shortcuts and Productivity Tips

Why Should You Learn Terminal Shortcuts?

Terminal shortcuts are the most effective way to multiply your working speed on the command line. Professional developers and system administrators spend a significant portion of their day in the terminal. Being able to edit text, navigate command history, and manage processes using only the keyboard without a mouse provides a tremendous productivity boost. The shortcuts and techniques you will learn in this guide will elevate your terminal usage to a professional level.

Memorizing these shortcuts may seem difficult at first, but after a few weeks of regular use, your muscle memory kicks in and these shortcuts become reflexes. The key is to try a few new shortcuts each day and make them habitual. Over time, your efficiency in the terminal will improve dramatically.

Ctrl Shortcuts

These shortcuts work in most shell environments including Bash and Zsh. They are Emacs-style shortcuts provided by the Readline library.

Process Control

  • Ctrl+C: Cancels the running command (sends SIGINT signal). Used to stop long-running or accidentally started commands.
  • Ctrl+D: Signals end of input (EOF). When used on an empty line, it closes the terminal session. You can also close interactive shells like Python and Node this way.
  • Ctrl+Z: Sends the running command to the background and suspends it (SIGTSTP signal). You can later bring it to the foreground with fg or resume it in the background with bg.
  • Ctrl+L: Clears the screen (same as the clear command). It preserves the current command line and only clears previous output.

Cursor Movement

  • Ctrl+A: Moves the cursor to the beginning of the line. Perfect for jumping to the start of a long command.
  • Ctrl+E: Moves the cursor to the end of the line.
  • Ctrl+F: Moves the cursor one character forward (same as the right arrow).
  • Ctrl+B: Moves the cursor one character backward (same as the left arrow).
  • Alt+F: Moves the cursor one word forward.
  • Alt+B: Moves the cursor one word backward.

Text Editing

  • Ctrl+W: Deletes the word to the left of the cursor. Ideal for quickly removing a mistyped parameter.
  • Ctrl+U: Deletes everything from the cursor to the beginning of the line. Use when you want to retype the entire command.
  • Ctrl+K: Deletes everything from the cursor to the end of the line.
  • Ctrl+Y: Pastes the last deleted text (yank). Used to restore text deleted with Ctrl+U or Ctrl+W.
  • Ctrl+T: Transposes the character under the cursor with the previous character. Useful for quickly fixing typos.
  • Alt+T: Transposes the word under the cursor with the previous word.

Search

  • Ctrl+R: Performs a reverse search through command history. As you type, the most recent matching command appears. Pressing Ctrl+R again moves to older results.
  • Ctrl+S: Performs a forward search through command history (not enabled in some terminals).
  • Ctrl+G: Cancels the search and returns to the command line.

Command History

Bash and Zsh store all commands you execute in a history file. Using this history efficiently saves you from retyping the same commands repeatedly.

History Commands

# Show entire command history
$ history

# Show last 20 commands
$ history 20

# Search through history
$ history | grep "docker"

# Clear history
$ history -c

# Repeat the last command
$ !!

# Use the last argument of the previous command
$ !$
# Example:
$ mkdir /var/www/new-site
$ cd !$
# Runs as cd /var/www/new-site

# Use the first argument of the previous command
$ !^

# Run a specific command from history by number
$ !42

# Run the last command starting with a specific word
$ !docker
# Runs the most recent command starting with "docker"

# Word substitution in the last command
$ echo "hello world"
$ ^world^mars
# Runs as echo "hello mars"

History Settings

# Add to ~/.bashrc or ~/.zshrc

# Increase history size
export HISTSIZE=10000
export HISTFILESIZE=20000

# Don't add duplicate commands to history
export HISTCONTROL=ignoredups:erasedups

# Save multi-line commands as a single line
shopt -s cmdhist

# Save history after every command
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"

# Add timestamps
export HISTTIMEFORMAT="%F %T  "

Defining Aliases

Save time by defining short aliases for frequently used long commands. Aliases should be added to your ~/.bashrc or ~/.zshrc file.

# Define aliases
$ alias ll='ls -alF'
$ alias la='ls -A'
$ alias l='ls -CF'

# Git shortcuts
$ alias gs='git status'
$ alias ga='git add'
$ alias gc='git commit -m'
$ alias gp='git push'
$ alias gl='git log --oneline --graph'
$ alias gd='git diff'

# Docker shortcuts
$ alias dps='docker ps'
$ alias dimg='docker images'
$ alias dstop='docker stop $(docker ps -q)'

# Navigation shortcuts
$ alias ..='cd ..'
$ alias ...='cd ../..'
$ alias ....='cd ../../..'

# Safety (ask for confirmation on dangerous commands)
$ alias rm='rm -i'
$ alias mv='mv -i'
$ alias cp='cp -i'

# Custom shortcuts
$ alias myip='curl -s ifconfig.me'
$ alias ports='ss -tlnp'
$ alias update='sudo apt update && sudo apt upgrade -y'

# List defined aliases
$ alias

# Remove an alias
$ unalias ll

Tab Completion and Brace Expansion

Tab Completion

The Tab key is the most fundamental productivity tool in terminal usage. It auto-completes file names, directory paths, command names, and even parameters for some commands.

# File name completion
$ cat Doc[Tab]
$ cat Documents/

# If multiple matches, press Tab twice to list them
$ ls D[Tab][Tab]
Desktop/    Documents/    Downloads/

# Command completion
$ sys[Tab][Tab]
systemctl  systemd-analyze  systemd-cat  ...

Brace Expansion

# Create multiple files or directories
$ mkdir -p project/{src,tests,docs,config}
# Creates project/src, project/tests, project/docs, project/config

# With number ranges
$ touch file_{1..10}.txt
# Creates file_1.txt, file_2.txt, ... file_10.txt

# With letter ranges
$ echo {a..z}
# a b c d e f ... z

# Nested brace expansion
$ mkdir -p project/{src/{main,test},docs/{api,user}}

# When creating backups
$ cp config.yml{,.bak}
# Copies config.yml to config.yml.bak

Command Substitution

# Use command output with $() syntax
$ echo "Today is $(date +%Y-%m-%d)"
Today is 2026-03-13

# Assign to a variable
$ FILE_COUNT=$(ls | wc -l)
$ echo "This directory has $FILE_COUNT files"

# Backtick syntax (old method, not recommended)
$ echo "User: `whoami`"

# Practical examples
$ tar -czf backup_$(date +%Y%m%d).tar.gz /var/www/
$ kill $(pgrep -f "python server.py")

tmux Basics

tmux (terminal multiplexer) allows you to create and manage multiple sessions within a single terminal window. Even if your SSH connection drops, your sessions continue running on the server.

# Install tmux
$ sudo apt install tmux    # Debian/Ubuntu
$ brew install tmux        # macOS

# Start a new tmux session
$ tmux

# Start a named session
$ tmux new -s project

# Detach from session — session continues in the background
# Ctrl+b, then d

# List existing sessions
$ tmux ls

# Reattach to a session
$ tmux attach -t project

# Basic shortcuts inside tmux (after Ctrl+b prefix):
# d       → Detach from session
# c       → Create new window
# n       → Switch to next window
# p       → Switch to previous window
# %       → Split pane vertically
# "       → Split pane horizontally
# arrow   → Switch between panes
# x       → Close current pane
# [       → Enter scroll mode (press q to exit)

Productivity Habits

  • Use tab completion constantly: Complete file names and commands with Tab instead of typing them manually. It is both faster and prevents typos.
  • Embrace Ctrl+R: Search through command history to avoid retyping long commands. This single shortcut alone can dramatically improve your productivity.
  • Create aliases: Define an alias for every long command you use several times a day.
  • Use pipes and redirection: Chain commands together to solve complex tasks in a single line.
  • Write scripts: Convert repetitive tasks with more than three steps into a shell script.
  • Use tmux: Instead of opening multiple terminal windows, use tmux panes and windows.
  • Read man pages: Use man command or command --help to learn the options of unfamiliar commands.
  • Manage your dotfiles: Keep configuration files like .bashrc and .vimrc under version control with Git.

Summary

Terminal shortcuts and productivity techniques can completely transform your command-line experience. Process control shortcuts like Ctrl+C, Ctrl+D, and Ctrl+Z, cursor movement shortcuts like Ctrl+A and Ctrl+E, history search with Ctrl+R, history expansions like !! and !$, alias definitions, tab completion, brace expansion, command substitution, and tmux — as you incorporate all these tools into your daily workflow, you will get far more out of the terminal. Remember: the best shortcut is the one you use every day until it becomes a reflex.