Shortcut Keys for Bash

August 7, 2012 | By

A list of 30 Bash shortcut keys that will save you time. Bash is the default shell in most Linux distributions and the most popular. The shortcuts are divided into 3 sections (navigation, editing and cutting and pasting) for easy reference.

 

Nanigation

Tab Auto-complete files and folder names
Shift + Page Up Scroll terminal output up
Shift + Page Down Scroll terminal output down
CTRL + R Search command line history
CTRL + L Clear the screen
CTRL + F Move forward one character
CTRL + B Move backward one character
Alt + F Move forward one word
Alt + B Move backward one word
CTRL + A Go to the beginning of the line
CTRL + E Go to the end of the line
CTRL + D Exits the shell (EOF)
CTRL + Z Pauses the current process and sends it to the background
CTRL + S Stops output to the screen (XOFF)
CTRL + Q Turns on output to the screen (XON)
CTRL + C Delete the entire line or kill the current process

 

Editing

CTRL + T Switch positions of current and previous characters
Alt + T Switch positions of current and previous words
Alt + U Change the current word (from cursor position to end of word) to uppercase
Alt + L Change the current word (from cursor position to end of word) to lowercase
Alt + C Change the current character to uppercase
CTRL + H Delete the character before the cursor. Similar to pressing backspace
CTRL + V Add a special character. e.g. CTRL+V CTRL+C will add ^C instead of canceling the current command
CTRL + _ Undo
Alt + Backspace Deletes from cursor position back to the first space

 

Cutting And Pasting

CTRL + K Cut text from cursor position to the end of the line
CTRL + U Cut text from cursor position to the beginning of the line
CTRL + W Cut word from cursor position to the beginning of the word
ALT + D Cut word from cursor position to the end of the word
CTRL + Y Paste the recently cut text

Filed in: Linux | Tags: ,

Comments (2)

  1. It should be noted that many of these keystrokes are appropriate when bash is operating with the readline option to use emacs keystrokes(the default). vi keystrokes can be used instead by issuing (or including in .profile… )

    set ‑o vi

    Additional command line programs that use readline include ftp, bc, MySQL and the perl debugger.

  2. PS Alt prefix is usually generated y pressing the esc key.