The bash shell - Linux terminal keyboard shortcuts



Hey!

Recently found out that there are some quite awesome shortcuts available that I've missed - extremely useful if you use the bash shell in *Nix.

To see which one you are using you can type 'chsh' in a terminal - this will tell you if you are using /bin/bash.

Go try them out! This can speed up your work in the terminal incredibly.

** Updated 2011-04-05 - there are many moooore! See this little link: faqshttp://www.faqs.org/docs/bashman/bashref_93.html#SEC100

You can see the bindings by typing "bind -P"

The easier shortcuts

Ctrl + AGo to the beginning of the line you are currently typing on. Extremely useful in those scenarios when left/right arrow keys do not work. Same as HOME button.
Ctrl + EGo to the end of the line you are currently typing on. Same as END button.
Ctrl + LClears the Screen, same as the clear command.
Ctrl + UClears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + HBackspace.
Ctrl + RLet’s you search through previously used commands. Hit again to roll through the hits in the history. Searches through .bash_history in the user's home directory.
Arrowkeys Up/DownSame as CTRL + P and CTRL + N. This will browse through the history. Hit enter to execute the command.
Ctrl + CKill whatever you are running.
Ctrl + DExit the current shell - logout.
Ctrl + ZPuts whatever you are running into a suspended background process. You can then use the terminal for something else. Type 'fg' in the terminal to restore the process.
Ctrl + WDelete the word before the cursor.
Ctrl + KClear the line after the cursor.
Ctrl + TSwap the last two characters before the cursor.
Esc + TSwap the last two words before the cursor.
Alt + FMove cursor forward one word on the current line.
Alt + BMove cursor backward one word on the current line.
TabAuto-complete files and folder names.
Shift + Page Up / DownScrolls through terminal buffer.

The shortcuts that are a little trickier

Ctrl + X *In a directory you have two files: awesomeapp1.deb and notawesomebutneededapp4.deb. You want to install both. In debian the program you call is "dpkg -i filename.deb". If you don't want to write out all the names, you can type this: dpkg -i *.deb CTRL+x * (first ctrl+x and then press the * on your numpad or * on your normal, like shift+') and then it will resolve the names so that your command will be "dkpg -i awesomeapp1.deb notawesomebutneededapp4.deb"
Ctrl + X Ctrl + VPrints something like this: GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
MacrosCTRL +X ( to start, CTRL +X ) to save. For example: first hit CTRL+x SHIFT+8 (this is on my keyboard layout) - then put in your commands. Everything you type after this is saved in a macro. Then CTRL+X SHIFT+9 to save. Then hit CTRL+x e to run the macro.

Have fun!