Follow this Blog!

Jan 22, 2013

f Comment

Learn The Most Useful Hot Keys and Shortcut Keys in the Unix Command Prompt in ONE minute!

Amazon Unix Operating System is one of the most common operating systems used in the world. As you enter a command in the command line or command prompt you often want to perform trivial tasks on the command you've entered such as 'delete to the beginning of the line', 'move cursor to end of the line', so on. How do you do these seemingly easy tasks? What combination of keys can achieve these goals on a Linux machine?

Read on to learn the MOST useful shortcut keys in a Unix or Linux machine's command prompt!

A Table of Useful Hot Keys in Command Prompt on Linux
The following is a table of the most useful hot keys for me. Many of these hot keys are the also used in the Emacs editor. So if you are an Emacs user you should be familiar with these shortcut keys.

C = Control key
E = Escape key

C-/ or C-_Undo the last action
C-dDelete or Kill a character
C-uDelete or Kill to beginning of line
C-kDelete or Kill to end of line
E-backDelete one word left
E-dDelete one word right
C-aMove cursor to beginning of line
C-eMove cursor to end of line
E-leftMove cursor left one word
E-rightMove cursor right one word
C-rSearch for a previous command. Once you are in this mode start entering parts of the command as hints. For example if you've entered 'tail -f /usr/local/bin/a/b/c/d/e/access.log' a while ago and you'd like to run this command now, you type C-r to get into the search mode, and then start typing 'tail -f' and you should see the matching command popping out as you type more.
C-r (while you are in search mode)Go to the next matching command without entering further hint. For example let's say you've run 'tail -f a.txt' and 'tail -f b.txt' before. When you are in search mode and start typing 'tail -f' you may see 'tail -f a.txt' or 'tail -f b.txt' show up. Let's say you want to run the other command. Simply type C-r to go to the next command that matches your inputted hint.

I've tested these commands in many Unix distributions successfully. I am currently using 'Linux ip-xxx 2.6.32-309-ec2 #18-Ubuntu SMP Mon Oct 18 21:00:20 UTC 2010 i686 GNU/Linux'
Easy right? If you have any questions about these shortcut keys let me know!
Please leave a comment here!
One Minute Information - by Michael Wen
Find Michael on Google or Facebook
ADVERTISING WITH US - Direct your advertising requests to Michael