Updated: June 11th, 2015

imageDuring my day-to-day activities, I use the Bash shell a lot. My #1 policy is to optimize the most frequently used activities as much as possible, so I’ve compiled these handy bash shortcuts and hints (tested in SecureCRT on Windows and Konsole on Linux). The article only touches on the default bash mode – emacs, not vi. If you haven’t specifically assigned your shell mode to vi (set –o vi), you’re almost certainly using the emacs mode. Learn these and your shell productivity will skyrocket, I guarantee it.

Update #1: In response to a few people saying this list is too short and “[he] could've added something to it, to atleast make it look longer” (quote from one of Stumbleupon reviewers), I want to clarify something. I deliberately did not include every single bash shortcut there is. I included what I personally thought were the best and most useful commands. I did not want to make the list too cluttered and wanted the cheat sheet to fit on one page without going to a smaller font size.


Download Version 1.3 (03/22/12):

And, for quick reference, here's the ugly html version:

Keyboard shortcut




Go to the beginning of the line (note that if you use GNU screen, you can use the Home button to do this, especially considering that Ctrl-A is a special control character in screen).


Go to the end of the line (note that if you use GNU screen, you can use the End button to do this).

Alt-B (or ESC, left arrow)

Jump back one word using a non-alphanumeric character as delimiter.

Alt-F (or ESC, right arrow)

Jump forward one word using a non-alphanumeric character as delimiter.

Ctrl-PGUP or Shift-PGUP

This may or may not work, and it works differently on different console apps. It will either scroll up one line at a time, 1 page at a time, or it may not work at all. I'm inclined to think it's not a bash shortcut at all.

Ctrl-PGDN or Shift-PGDN

Same as the above but scrolling is done in the opposite direction.


Previous/Next command in history. This one is way too obvious but I'm including it for completeness.


History search. For example, Ctrl-R svn Ctrl-R Ctrl-R … will cycle through all recently run commands with the ‘svn’ in them. It is one of the most useful shortcuts in bash.


Takes whatever line was after the line you selected with Ctrl-R and makes it your next command.

Command Line Manipulation


Cut one word backwards using white space as delimiter.


Cut one word backwards using a non-alphanumeric character as delimiter (different from Ctrl-W, for example, abc;bcd will cut to abc;).


Cut everything forward to end of line.


Cut everything backwards to beginning of line.


Transpose the current character with the previous one. I almost never use this. Never mind, I never use it, but someone might find it useful.


Transpose the word at cursor with the one before cursor. In other words, swap them around.


Paste whatever was cut by the last cut command.


Insert the next character literally. For example, Ctrl-V TAB inserts the actual TAB character. This shortcut is often misunderstood because of mistyping Ctrl-V and not realizing what it does.


Undo the last command. Don’t forget – it’s Ctrl-Shift-MINUS, not Ctrl-MINUS.


Revert all changes to current line. Very useful if you accidentally modify a command in history.


Uppercase/lowercase/capitalize from cursor to end of word and move cursor past end of word.

Terminal control


Clear screen while keeping whatever is already typed in the command line intact.


Suspend currently running terminal.


Unsuspend the terminal suspended by Ctrl-S. You need to be aware of this shortcut because 99% of the time you’ve accidentally pressed Ctrl-S and need to undo its effects.


Suspend the currently running process (usually followed by bg to resume it in the background or fg to resume in the foreground).


Autocomplete. Start typing, then hit TAB. You will either get a list of possible completion values (2 TABs needed) or the only choice will be filled in (only 1 TAB is needed). This shortcut is quite obvious and well known, so I put it at the bottom of the list.

Tip: By the way, as duly noted in the comments, all of these tricks work on the mysql command line, so you can, for example, ctrl-R through your previously executed mysql commands.

Hope you guys will find this list helpful. I think it is relatively complete, but feel free to add any omissions.

● ● ●
Artem Russakovskii is a San Francisco programmer and blogger. Follow Artem on Twitter (@ArtemR) or subscribe to the RSS feed.

In the meantime, if you found this article useful, feel free to buy me a cup of coffee below.

  • I use these sometimes, but I find that "set -o vi" as you said in the beginning solves all of my productivity woes.

  • Erkan

    Why is this blogentry on planetMYSQL.org?

  • Version 1.0 of the cheat sheet is up in PDF, DOC, and DOCX formats. Subscribe to comments using the link below for updates.

  • Cliff

    @Erkan: probably because not everyone uses phpMyAdmin. sometimes it's easier for me to SSH into my server, and at that point, I'm at the mercy of bash (or it's at my mercy…). So, not directly related to MySQL, but very practically useful for many admins. Cheers!

  • @Cliff, thank you. Indeed, you can use all of these tricks, including ctrl-R on the mysql prompt, so they are very handy for mysql admins and users alike.

  • Ikai Lan

    Suspend and unsuspend totally pwned me when I was a n00b first moving from Windows to Linux and I kept hitting Control-S to save stuff in VIM.

    Note that not all of these work for OS X, specifically, the Alt commands. And dude, how come you put Control-T in here but not Control-Z?

  • Thanks, Ikai, don't know why ctrl-Z evaded the list, it's quite important indeed.

    Updated to v1.11:
    – added ctrl-Z
    – cleaned up some formatting issues

  • mannan

    could anyone tell me a site for bash……very gud one…..which starts from the beginning n goes till the end….

  • zhi

    thanks for cheat sheet.

  • Hi Artem,

    Have you seen my two articles on bash vi and emacs editing mode shortcuts?

    Mine also have cheat sheets with them (one for each mode).

    They are here:




  • Peteris, thanks for the links – I haven't seen them before. 😉 Your cheat sheets are quite complete (2 pages, small font).

    "M-Rubout" – you weird Latvians 😀

  • Oh, I see. I should probably make a "come-back" article on catonmat for the new readers who haven't seen them.

    There is also "The Definitive Guide to Command Line History":


    Rubout is the official name of the key, afaik! 😉

  • Version 1.2:
    – added Alt-U/L/C: Uppercase/lowercase/capitalize from cursor to end of word and move cursor past end of word.
    – added Alt-R: Revert all changes to current line. Very useful if you accidentally modify a command in history.
    – added Ctrl-_: Undo the last command. Don’t forget – it’s Ctrl-Shift-MINUS, not Ctrl-MINUS.
    – various changes to formatting and wording.

  • Ernie

    This will come in handy for a lot of linux users I am going to try to learn more about this myself I have used linux for 8 years but have not yet played with scripting much. I found a site from searching the Linux Search Engine that has some basic info in it that may come in handy for some who are getting acquainted with this. Hope this is helpful to someone. bash shell info

  • Ozh

    Cool list, but to be a real cheat sheet it needs to be a printable A4 pdf 🙂

  • @Ozh
    do the included PDF and Word formats not work for you? :-/

  • These aren't "bash" shortcuts, per se. They're readline shortcuts. Any program that uses readline to manage input will support them. That's why they work in MySQL, as well as many other programs. In fact, if you have the rlwrap program installed, you can wrap ANY program in a readline instance! Try installing it, and then typing:

    $ rlwrap cat

    The readline utility can also be highly customized by using the ~/.inputrc file. I recommend checking it out:

    $ man readline

    For a list of handy bash shortcuts, check out http://commandlinefu.com

  • @Isaac
    Thanks for the clarification on readline!

  • Unix Shells | Udshells

    These are soem very usefull tips, well laid out and easy to understand thanks for the post!

  • Really a great reference, i tend to use ctrl+a and ctrl+U quite a lot and TAB of course. They make life easier. Linux is really about shortcuts anyway.

  • teknoloji

    Thanks for sharing

  • Thanks a lot of the tips.

  • I like to use vi as the command-line editor, eg; 'set -o vi'. Once set, you can search through the command history with esc-K, and use vi command to edit the line (replace words, characters, etc.) It's generally easier than back-spacing and re-typing (for those familiar with vi).

  • What if you were on a Mac?? 🙂

  • Bris

    Can i execute a shell script when i enter a particular pattern in my bash shell like an IP address?

  • Jeff S

    I download the files but they seem to be broken. The pdf doesn't work. The other two have woes as well. Is there an issue and can it be fixed??

  • whall

    This is a great list. Since you seem to have a line free, you might want to add CTRL-O right after CTRL-R. CTRL-O, once I learned it, became very useful when using RCS and other commands that go in pairs.

    Let's say you do your ci/co process:

    # rcs -i myfile.pl
    # ci -u myfile.pl
    # co -l myfile.pl

    Now the file is checked out and locked by you. You do lots of vim, perl -wc and all sorts of testing. Then you're ready to repeat the ci/co process.

    So you do your trusty CTRL-R, type
    "ci" and CTRL-R if needed to find the "ci -u myfile.pl" piece.

    Now, instead of pressing [Enter], you press CTRL-O. This presses [enter] for you, but automatically tees up the "co -l myfile.pl" line as your next line, waiting you to press [Enter].

    CTRL-O takes whatever line was after the line you selected with CTRL-R and makes it your next command.

    Hope this helps!

  • didi

    > … it’s Ctrl-Shift-MINUS, not Ctrl-MINUS.

    I expected that, but in my bash shortcut Ctrl-MINUS also works and I don't know why, as bind lists only:
    "\C-x\C-u": undo
    "\C-_": undo
    Can you explain that?

    • didi

      OK, after further digging I see it is on keybord level as Ctrl-7 and Ctrl-/ also generate ^_ character.

  • Pingback: Bash scripting | Andreas' Blog()

  • Pingback: Buy Vps Broken Arrow – Buy Cheap VPS()

  • Pingback: Chuleta: Atajos de teclado para Shell Bash | rm-rf.es()