Follow this Blog!

Jan 22, 2013

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 keyE = Escape key

C-/ or C-_

Undo the last action

C-d

Delete or Kill a character

C-u

Delete or Kill to beginning of line

C-k

Delete or Kill to end of line

E-back

Delete one word left

E-d

Delete one word right

C-a

Move cursor to beginning of line

C-e

Move cursor to end of line

E-left

Move cursor left one word

E-right

Move cursor right one word

C-r

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