Linux Blog

Bash Tips for more efficient terminal usage

Filed under: Linux for Newb's,Linux Software — at 5:36 pm on Monday, November 23, 2009

Here are some tips for working in the shell that I use on a daily basis. These may be known to most veterans, please contribute your favorite shortcuts to the comments. But for the most part this is not for the uber leet Linux geek, this is for those new to the terminal.

- Gives you suggestions / completes stuff for you. Type a, Press it twice, it will make your life a lot easier.

- Remove word behind cursor.

- Undo / Erase everything from cursor to beginning of the line

- Type out whatever you typed out last, can be combined with tools like sudo

- Go forward to the end of the previous word

- Move cursor back to the beginning of the previous word

- You’re done? Press ctrl+d to logout. If you’re in a virtual terminal, it may also close the window.

- Stop the current process. Say you run gvim, and then you want to spawn another process. Press ctrl+z, then type bg. Once you’re done with the “other” process, you may type fg to bring it back into the foreground.

Random Man Pages:


Comment by Claudiu

November 23, 2009 @ 7:05 pm

ctrl + r = search in (command) history

Comment by georges

November 24, 2009 @ 3:44 am

ctrl+r lets you search in your history

!$ is replaced by the last word of the last command

esc+. is same as above, but replacement is made instantly, so you can edit if needed

Comment by zlty

November 24, 2009 @ 7:16 am

ctrl+z – it is not stopping the process actually, it puts in background where it still works, same as typing “command&”.
You wrote alt+b, alt+f it works (on my box) with ctrl. We also have ctrl+e which takes cursor to the end of line, ctrl+arrows which moves cursor to words.

Comment by Linerd

November 24, 2009 @ 9:40 am

I like to use the up and down arrow keys to recall previous commands from the shell history. Press the up arrow once to type the most recent command. Press it twice to type the second most recent, etc. If you go too far, the down arrow will take you forward again through the command history. Once you find the command you want, just hit enter. You can also use this in combination with your other line editing tips to edit the command before you execute it.

Comment by

November 24, 2009 @ 10:16 am

Thank you guys for all the comments, I don’t know how I could forget CTRL+R, very useful.
@ZLTY could be something to do with keyboard mappings, because ctrl+b/f on mine are the same as left / right arrows. As far as stopping the process, I battled with that word. You are correct, it is really “suspending the process” but since it said “stopped” in the terminal I thought that was appropriate.

Comment by Technopotomus

November 27, 2009 @ 2:10 pm

Even though it’s not as useful and powerful as the others, ctrl-L is handy when I just want a clean screen. Not too often, but sometimes especially if I have several sessions to a few boxes open, I like to clean up some of the clutter.

Comment by bdk

December 7, 2009 @ 9:27 am

If your a systems engineer, you may eventually have to dive into a router or a switch and most, if not all, control + key combos work just like they do under Linux. I use them so much that I find myself using them within an PSi and even in my emails. CTRL+ and VI commands become so second nature it is scary.

Comment by Bojan

December 15, 2009 @ 8:42 am

Nice collection of shortcuts, you should update this post and enter tips from comments.

Comment by

December 17, 2009 @ 12:28 pm

Agreed, just have not got around to it yet.

Comment by Linux tips

September 28, 2010 @ 12:15 pm

Nice collection of shortcuts and its very appreciable,this might be very use full to beginners…

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>