_____ _ ___ _________ __ |_ _|__ _ __ _ __ ___ (_)_ __ __ _| \ \ / / ____\ \/ / | |/ _ \ '__| '_ ` _ \| | '_ \ / _` | |\ \ / /| _| \ / | | __/ | | | | | | | | | | | (_| | | \ V / | |___ / \ |_|\___|_| |_| |_| |_|_|_| |_|\__,_|_| \_/ |_____/_/\_\
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.
These shortcuts work in most shell environments including Bash and Zsh. They are Emacs-style shortcuts provided by the Readline library.
fg or resume it in the background with bg.clear command). It preserves the current command line and only clears previous output.Bash and Zsh store all commands you execute in a history file. Using this history efficiently saves you from retyping the same commands repeatedly.
# 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"
# 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 "
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
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 ...
# 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
# 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 (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)
man command or command --help to learn the options of unfamiliar commands.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.