Share

Updated: June 9th, 2009

26 Responses to “Mastering The Linux Shell – Bash Shortcuts Explained (Now With Cheat Sheets)”

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

  2. Erkan says:

    Why is this blogentry on planetMYSQL.org?

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

  4. Cliff says:

    @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!

  5. @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.

  6. Ikai Lan says:

    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?

  7. 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

  8. mannan says:

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

  9. zhi says:

    thanks for cheat sheet.

  10. 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:

    http://www.catonmat.net/blog/bash-vi-editing-mode-cheat-sheet/

    http://www.catonmat.net/blog/bash-emacs-editing-mode-cheat-sheet/

    Peteris

  11. 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 :D

  12. 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":

    http://www.catonmat.net/blog/the-definitive-guide-to-bash-command-line-history/

    Rubout is the official name of the key, afaik! ;)

  13. 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.

  14. Ernie says:

    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

  15. Ozh says:

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

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

  17. 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

  18. @Isaac
    Thanks for the clarification on readline!

  19. Unix Shells | Udshells says:

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

  20. Spyros says:

    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.

  21. teknoloji says:

    Thanks for sharing

  22. Scott says:

    Thanks a lot of the tips.

  23. 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).

  24. 3 Pings:
  25. [...] know I did not cover tilde expansions, shell parameter expansions or bash key commands. You will want to check those out as well, but I find them less useful than what I've covered [...]

  26. [...] know I did not cover tilde expansions, shell parameter expansions or bash key commands. You will want to check those out as well, but I find them less useful than what I've covered [...]

  27. [...] features of PostgreSQL Hidden features of SQL Server Other Hidden features of Bash – also see my bash cheatsheet. Hidden features of CSS Hidden features of Eclipse Hidden features of HTML Hidden features of [...]

Leave a Reply

Connect with Facebook