Whether you're a systems administrator managing production servers or an enthusiast experimenting in a home lab, spending 90% of your time inside a terminal is a common reality—even when working in a full desktop GUI environment. The command line offers unparalleled flexibility, but it can quickly become cumbersome when you find yourself repeatedly typing long commands, running long-duration tasks, or constantly modifying configuration files. This post serves as a practical, everyday reference covering essential Linux terminal shortcuts alongside three indispensable tools: Tmux, Vim, and Nano.
Prerequisites
The only prerequisite for this guide is access to a terminal on any Linux distribution. It doesn't matter how your Linux environment is set up—you can follow along using:
- A bare-metal Linux installation
- A Virtual Machine (VM)
- Windows Subsystem for Linux (WSL2)
- A remote SSH terminal session
1.0. Essential Linux Terminal Shortcuts
Working efficiently in the terminal isn't about how fast you type—it's about avoiding repetitive keystrokes. These native GNU Readline keyboard shortcuts work by default in most standard Linux shells (like bash and zsh).
1.1. Cursor Navigation
Moving character-by-character with arrow keys is slow, especially for long commands or parameters. Use these to jump around instantly:
| Shortcut | Action |
| Ctrl + A | Jump the cursor to the beginning of the command line. |
| Ctrl + E | Jump the cursor to the end of the command line. |
| Alt + F or Alt + → or Ctrl + → | Move forward by one word. |
| Alt + B or Alt + ← or Ctrl + ← | Move backward by one word. |
1.2. Command Line Editing & Deleting
Instead of holding down Backspace for several seconds, clear whole words or entire lines with a single key combo:
| Shortcut | Action |
| Ctrl + W | Cut/delete the word immediately before the cursor. |
| Alt + D | Cut/delete the word immediately after the cursor. |
| Ctrl + U | Cut/delete everything from the cursor back to the beginning of the line. |
| Ctrl + K | Cut/delete everything from the cursor forward to the end of the line. |
| Ctrl + Y | Paste ("yank") whatever text you last cut using Ctrl + W, Ctrl + U, or Ctrl + K. |
1.3. Terminal & Process Control
Keep your workspace clean and manage running tasks smoothly without reaching for your mouse:
| Shortcut | Action |
| Ctrl + L | Clears the screen (preserves your active typing line). |
| Ctrl + C | Force-kills the active foreground process. |
| Ctrl + Z | Suspends the running process and sends it to the background. |
| Ctrl + D | Sends EOF signal (exits the session or closes the terminal). |
1.4. History Search & Command Reuse
Instead of hitting the Up Arrow fifty times to find a command you ran an hour ago, use these commands:
Reverse History Search
- Press Ctrl + R in your prompt.
- Start typing any part of the command you ran earlier (e.g., docker or systemctl).
- Press Ctrl + R repeatedly to cycle backward through previous matching commands.
- Once you find it, hit Enter to execute it immediately, or hit the Right Arrow to edit it first.
- Hit Ctrl + G if you want to cancel the search without executing anything.
Useful History Expansion Shortcuts
- !! (pronounced "bang bang"): Re-executes the last command you ran.
- Example: You ran apt update and got a permission error. Just type sudo !! to run sudo apt update.
- !$: Evaluates to the very last argument of your previous command.
- Example: If you created a folder with mkdir -p /var/www/my-site, you can immediately switch into it by typing cd !$.
2.0 Tmux
Have you ever had an SSH session drop due to a network glitch right in the middle of a long system update? Or found yourself opening five separate terminal tabs just so you could monitor logs while editing a configuration file?
Tmux (Terminal Multiplexer) is a lifesaver in these scenarios. It keeps your terminal sessions running in the background on the server—even if your internet cuts out or you close your terminal window. Furthermore, it allows you to split a single screen into multiple panes and windows. On almost all standard Linux distributions (including Ubuntu, Debian, CentOS/RHEL, and Fedora), tmux is not pre-installed by default.
If tmux isn't installed on your system, install it using your distribution's package manager:
# Ubuntu / Debian / WSL
sudo apt install tmux -y
# Fedora / RHEL / AlmaLinux
sudo dnf install tmux -y
# Arch Linux
sudo pacman -S tmux
2.1. Session Management (Terminal Commands)
Use following commands from your regular shell prompt to create, list, and reconnect to sessions:
| Action | Command |
| Start an unnamed session | tmux |
| Start a named session | tmux new -s session_name |
| List all active sessions | tmux ls |
| Attach to the last active session | tmux a |
| Attach to a specific named session | tmux a -t session_name |
| Kill a specific session | tmux kill-session -t session_name |
Note: Named vs. Unnamed Sessions
Running just tmux will create an unnamed session automatically numbered by Tmux (e.g., 0, 1, 2). While quick for simple tasks, using tmux new -s session_name is strongly recommended when managing multiple tasks so you can easily identify them later in tmux ls.
2.2. The Tmux "Prefix Key"
Once you are inside a Tmux session, Tmux listens for a special shortcut combination called the Prefix Key before executing any layout or session command. The default Prefix Key combination is Ctrl + B. To use any Tmux shortcut, you press Ctrl + B, release both keys, and then press the command key(e.g., D to detach).
2.3 Key Shortcuts For Working Inside Tmux
All shortcuts below assume you press Prefix Key (Ctrl + B) first, release it, and then hit the indicated key:
Session Controls
| Shortcut | Action |
| Prefix then D | Detach from session (keeps all processes running in background). |
| Prefix then $ | Rename the current session. |
Splitting and Managing Panes (Split Screens)
| Shortcut | Action |
| Prefix then % | Split current pane vertically (side-by-side). |
| Prefix then " | Split current pane horizontally (top and bottom). |
| Prefix then Arrow Key | Move focus to adjacent pane. |
| Prefix then Z | Toggle zoom on active pane (maximize / restore). |
| Prefix then X | Close active pane (prompts for confirmation and terminates any process running within it). |
Managing Windows (Tabs within a Session)
| Shortcut | Action |
| Prefix then C | Create a new window. |
| Prefix then N | Switch to the next window. |
| Prefix then P | Switch to the previous window. |
| Prefix then 0–9 | Jump directly to a window by its index number. |
| Prefix then , | Rename the current window. |
2.4. Rescuing a Disconnected Session
If your network drops or your terminal crashes while running a process inside Tmux, simply log back into your server via SSH and run:
3.0. Terminal Text Editors: Nano
If you just need to edit a line or two in a configuration file without memorizing complex key combinations, Nano is your best friend. It is beginner-friendly, modeless (what you type is immediately written to the file), and displays its primary shortcuts at the bottom of the screen.
3.1. Nano Installation
While Nano is installed by default on distributions such as Ubuntu Desktop, or Linux Mint etc., it is common to not be included in minimal installations. In such situations, you can install Nano using the following commands:
# Ubuntu / Debian / WSL
sudo apt install nano -y
# Fedora / RHEL / AlmaLinux
sudo dnf install nano -y
# Alpine Linux
apk add nano
3.2. Entering Nano
To launch Nano from your regular terminal prompt, pass the filename (or path) as an argument:
sudo nano <file/path/file_name>
3.3. Nano Key Shortcuts
As mentioned previously, Nano displays its main shortcuts at the bottom of the screen. In Nano's on-screen cheat sheet:
- ^ stands for the Ctrl key.
- M- stands for the Alt (or Meta) key.
| Shortcut | Action |
| Ctrl + O | Save changes ("WriteOut") without quitting. |
| Ctrl + X | Exit Nano (prompts to save if there are unsaved changes). |
Alt + A or Ctrl + ^ | Set/unset a mark to select text. |
| Alt + 6 | Copy current line or selected text to clipboard. |
| Ctrl + K | Cut current line or selected text. |
| Ctrl + U | Paste ("Uncut") text from clipboard. |
| Ctrl + W | Search text ("Where Is"). |
| Ctrl + \ | Search and replace text. |
| Alt + / | Jump to the very bottom of the file. |
| Ctrl + _ | Jump to a specific line number. |
4.0. Terminal Text Editors: Vim
There is a running joke in the IT industry that half of all developers are still trapped inside a Vim session they opened in 2018, desperately trying to figure out how to exit. The reason Vim causes initial confusion is that it is a modal editor—pressing keys executes commands rather than typing text unless you are explicitly in Insert Mode. Despite the learning curve, Vim is exceptionally useful. It is packed with high-speed editing features and—unlike Nano—it is pre-installed on virtually every Linux system in existence, even in minimal server installations.
4.1. Vim Modes
- Normal Mode: Default mode when Vim opens. Keys perform commands (navigate, copy, delete), not typing.
- Insert Mode: Allows you to type and edit text normally. Press i from Normal Mode to enter.
- Command-line Mode: Used for file operations (saving, quitting, search/replace). Press : from Normal Mode to enter.
Note: If you ever get lost or stuck, press the Esc key a couple of times. This always safely returns you to Normal Mode.
4.2. Saving & Quitting
To save or quit, press Esc to enter Normal Mode, type the colon(:), enter your command, and press Enter:
| Command | Action |
| :q! | The Panic Button: Force quit immediately and discard all unsaved changes. |
:wq (or :x) | Save changes ("write") and quit Vim. |
| :w | Save changes without quitting. |
| :q | Quit (only works if you haven't made any unsaved changes). |
4.3. Editing & Navigation (Normal Mode Shortcuts)
All of these shortcuts are pressed while in Normal Mode (press Esc first):
| Shortcut / Command | Action |
| i | Enter Insert Mode before the cursor. |
| a | Enter Insert Mode after the cursor. |
| dd | Cut / delete the current line. |
| yy | Copy ("yank") the current line. |
| p | Paste copied or cut text below the active line. |
| u | Undo the last action. |
| Ctrl + R | Redo the last undone action. |
| gg | Jump to the top of the file. |
| G | Jump to the bottom of the file. |
| /pattern | Search forward for text (Press n for next match, N for previous). |
| :%s/old/new/g | Replace all instances of old with new across the entire file. |
| :%s/old/new/gc | Replace all instances in the file, but confirm (y/n) before each. |
| :s/old/new/g | Replace all instances on the current line only. |
Mastering the Linux command line isn't about memorizing every shortcut—it's about building muscle memory for the workflows that save you time every single day. Don't try to memorize all these shortcuts at once! Pick two or three new commands to incorporate into your daily workflow this week—like Ctrl + R for history search or tmux for remote sessions. Bookmark this cheat sheet for quick reference as you build up that muscle memory. Happy terminal tweaking!
Comments
Post a Comment