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