45 Comments
- osearth, on 10/12/2007, -1/+31Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + H Same as backspace
Ctrl + R Let’s you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a background process.
Ctrl + W Delete the word before the cursor
Ctrl + K Clear the line after the cursor
Ctrl + T Swap the last two characters before the cursor
Esc + T Swap the last two words before the cursor - triplep, on 10/12/2007, -0/+11Not always useful:
"Ctrl + Z Puts whatever you are running into a background process"
Ctrl + z stops your job and drops it into the background. The process does not continue to run. If you issue a Ctrl+z followed by 'jobs' you'll get a listing of jobs, including the one you just sent to the background. To run the command in the background, use 'bg %x' where x is the corresponding job number - venkat23, on 10/12/2007, -2/+1310 shortcut commands going to front page
- krazikamikaze, on 10/12/2007, -0/+10To see ALL bindings in bash run "bind -P".
The functions on the left are from the readline library. I'm sure you can find a description of them on google if they aren't self-explanatory. - triplep, on 10/12/2007, -0/+9(oops, hit backspace and went back in browser history)
To bring the command back to the foreground using 'fg %x' where x is the job number.
If the job finishes while the process is backgrounded, it will have a status of 'Done' when the 'jobs' command is issued - lambmj, on 10/12/2007, -0/+6bg without a job number puts the last suspended job into the background. So to put a job in the background do this:
Ctrl + z
bg
Fwiw the linked list is lame and has been covered before. - rhettnyedotorg, on 10/12/2007, -2/+8don't forget my favourite
TAB - auto-complete for file/folder name
i will be using some of these. digg+ - capiCrimm, on 10/12/2007, -3/+7umm... does the author realize that bash just uses the emacs commands? You can also switch it to vim mode. Burried for being common knowledge and in any decent bash tutorial or book.
- quick1, on 10/12/2007, -0/+4FYI, if your a vi fan like me, you can set bash to use vi on the command line by editing the inputrc (ie vi /etc/inputrc)
and then adding the two lines
set editing-mode vi
set keymap vi
It sticks you in insert mode automatically when you open a command line, then you can hit esc... - DontSayFanboy, on 10/12/2007, -0/+3Ctrl-S and Ctrl-Q send flow control characters
XOFF - stop transmitting (CTRL-S in many cases)
XON - start transmitting (CTRL-Q in many cases)
Try CTRL-Q when your session freezes
If you find yourself freezing your session accidentally and you don't see this feature ever being useful to you, here is how to disable it (in your .bashrc)
# disable XON/XOFF flow control (^s/^q)
stty -ixon - eosp, on 10/12/2007, -0/+3C-a a for you then.
- howtogeek, on 10/12/2007, -0/+3It stops screen scroll... Ctrl + Q will restore it. Didn't seem very useful, so I didn't include it.
- inactive, on 10/12/2007, -0/+2So, what's your favorite shell?
- bigtomrodney, on 10/12/2007, -0/+2@BearOwned
Nobody with any real experience would call someone willing to learn a 'n00b'.
That kind of namecalling is reserved for twelve year olds with something to prove. - inactive, on 10/12/2007, -1/+3Bash is the default shell for OS X, these work for the OS X terminal as well, in case anyone was wondering...
- Markie1006, on 10/12/2007, -0/+2yea - vi-mode rules (been using it for the last 10 years). No more having to remember emacs-style keystrokes.
All the power of vi - on the commandline.
Also pressing 'v' opens the current commandline in vi/vim - mackstann, on 10/12/2007, -0/+2Also worth noting is that bash's vi mode is pretty crappy and doesn't work quite right with respect to the escape key. pdksh's is better.
- rockets, on 10/12/2007, -0/+2I don't think he realizes that. Makes you wonder if he even knows what emacs is.
- clayton191, on 10/12/2007, -0/+1Decent list. FYI, I subscribe to dailyshortcut.com and read it pretty religiously. Ton of mouse-less love there...
- R2C13, on 10/12/2007, -0/+1I prefer to use vi key bindings on the command line.
set -o vi
and keep your fingers on the home keys. :) - shakin, on 10/12/2007, -1/+2"TAB - auto-complete for file/folder name"
Bash's auto-completion is kind of lame. The Fish shell has some nice features that Bash doesn't, including better auto-completion. I don't use Fish as my default shell, but it's nice to use sometimes. I usually keep one desktop shortcut to open a term with Bash and another to open one with Fish.
Fish has:
- error highlighting when you make a mistake
- auto-completion of host name (eg. for ssh)
- it gives you info about items it can auto-complete with (mime types, program descriptions)
- tab completion when using wildcards
- uses the X clipboard (some terminal emulators help bash with this, but they're not perfect)
- uses Gnome or KDE default application to open non-executable files.
fish: http://roo.no-ip.org/fish/
article about fish: http://lwn.net/Articles/136232/ - dhulser, on 10/12/2007, -1/+2don't worry... i thought they were talking about bash.org....
- thrillho, on 10/12/2007, -0/+1What does Ctrl + S do? Everytime I hit that (by accident), it freezes my session.
- ahill7, on 10/12/2007, -1/+2These shortcuts are nice, and work well for bash sessions. Unfortunately, I'm usually running screen on top of bash so Ctrl-A is the hotkey for manipulating screen behavior.
- bigsmoke, on 10/12/2007, -0/+1I'm not the first to mention that most of these shortcuts are actually readline shortcuts. I've published a more extensive, very readable list of Readline/Bash shortcuts at http://www.bigsmoke.us/readline/shortcuts
- Scarblac, on 10/12/2007, -0/+1ctrl-S isn't particularly useful. However, there are a lot of people who have no idea how to get control back when they accidentally type it... ctrl-Q is very useful to know about :-)
- pixelbeat_, on 10/12/2007, -0/+1http://www.pixelbeat.org/lkdb/readline.html
http://www.pixelbeat.org/lkdb/bash.html - bedwyr, on 10/12/2007, -0/+1!! - may also change permissions to super-user access (like 'sudo'), depending on '/usr/local/lib/bang.allow' configuration
! - may allow invocation of a program with super-user permission - knutert, on 10/12/2007, -0/+1I use this one from that article all the time:
M-. paste the last word from the previous line
For example, instead of
cp file1 folder1/folder2
cd folder1/folder2
just type
cp file1 folder1/folder2
cd M-. - knutert, on 10/12/2007, -0/+1Fish is great the few times you need the extra features, but it's a bit too slow compared to bash to be worth it, IMO.
Oh, and I can't believe I didn't know the Ctrl + R command, no more typing up,up,up,up,up,up,up! - treehead, on 10/12/2007, -0/+1A better (more extensive and more accurate) list was already submitted.[0]
The action associated with CTRL + D is inaccurate. This actually deletes a character at the cursor.[1] The Bash keybindings closely follow those established by Emacs.
Come to think of it, the Bash Manual [3] is probably the best list. But then, it's not as sexy as a blog entry, right?
[0] http://digg.com/linux_unix/_Bash_Shell_Shortcuts
[1] http://www.gnu.org/software/bash/manual/bashref.html#SEC102
[2] http://www.gnu.org/software/bash/manual/bash.html - thrillho, on 10/12/2007, -0/+1thanks
- linuxunixperl, on 10/12/2007, -0/+0CTRL-Y will paste whatever you cleared with CTRL-U
- unikuser, on 10/12/2007, -0/+0I changed my screen control character to ctr+j for that reson.
- Plotinus, on 10/12/2007, -0/+0Also
!! - run last command in history
!+any letter - run last command of that letter
and instead of ctrl+R you can just type 'history' on the command line - addw, on 10/12/2007, -0/+0Lots of really useful things missing - like the kill ring. Try this instead:
http://www.phcomp.co.uk/TechTutorial/ReferenceSheets/BashKshRef.php - howtogeek, on 10/12/2007, -12/+12I'm... kinda surprised to see this particular article on the front page of digg... I've written a lot of other articles that seemed a little more worthy.
Still, thanks for the digg! - ko16736, on 10/12/2007, -2/+2I thought this said Keyboard Shortcuts for Bush.
Imagine my surprise, when instead of humorous euphemisms about our President, I get several commands that are useful in an alternative operating system!
=O - cynyr, on 10/12/2007, -0/+0Those shortcuts assume you have not done "set -o vi", and bash can have all those features that fish has, look at the bash-completion project, http://www.caliban.org/bash/index.shtml#completion ... so how is this news?
- Bonzodog, on 10/12/2007, -1/+1This is good, very good. I've been using linux as a sole OS at home for 10 years this year, and didn't actually know any of these. You live and Learn.
- FluffyArmada, on 10/12/2007, -4/+1You can also just type bg and it will revive the last process you just Ctrl-Z'd in the background. Instead of having to worry about the PID.
edit: sorry, I didn't see the comment directly below mine X( - tgone, on 10/12/2007, -8/+3buried. this is common knowledge...not news.
- GoldYoshi, on 10/12/2007, -6/+0Hah, I tried this a looong time ago. It is VERY boring and lame to do...
- oshu, on 10/12/2007, -10/+4To be accurate, they are actually:
Ctrl + a Go to the beginning of the line you are currently typing on
Ctrl + e Go to the end of the line you are currently typing on
Ctrl + l Clears the Screen, similar to the clear command
Ctrl + u Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + h Same as backspace
Ctrl + r Let’s you search through previously used commands
Ctrl + c Send a TERM signal to whatever you are running
Ctrl + d Send an EOF to signal the end of input (bash happens to exit on EOF by default)
Ctrl + x Suspends the current process into the background.
Ctrl + w Delete the word before the cursor
Ctrl + k Clear the line after the cursor
Ctrl + t Swap the last two characters before the cursor
Esc + t Swap the last two words before the cursor


What is Digg?
Browsing Digg on your phone just got easier with our enhancements to the