Useful Linux bash tricks

via Simple Help by Sukrit Dhandhania on 1/20/09

Linux

I use the Linux command line extensively, both on my local machine or when I’m connected to a remote server. There are some keyboard shortcuts that I want to share with you which have made my life on BASH a lot easier. I have not come across too many books that have documented these shortcuts and I think they are quite important to improve your productivity while on the command line.

1. Ctrl + r

This keyboard shortcut is for running a reverse search in your command line. To use this shortcut hold down the “Control” key in your terminal interface and hit the “r” while the “Control” key is still pressed. you should get a message like this:

(reverse-i-search)`’:

Now begin typing a command you used earlier. BASH will automatically complete your command. You can keep hitting the “Ctrl + r” combination to search further.

2. Ctrl + a

This shortcut makes your cursor jump to the beginning of the line. When you have typed a few works in your terminal hit the key combination of “Control + a” and you will reach the beginning of the line you are typing in.

3. Ctrl + e

This shortcut is similar to the previous one, except it makes your cursor jump to the other end of the line, the end. Type this key combination when in the middle of a line you are typing and you will jump right to the end of the line.

4. Ctrl + w

Using this shortcut will result in the deletion of one word to the left of the cursor. So if you are in the middle of a line that you are typing hitting “Control + w” will delete one word before the cursor.

5. ESC + d

This shortcut is the opposite of the previous one. Hitting “Escape + d” in your terminal will delete one word to the right of the cursor.

6. Ctrl + k

This is a very powerful shortcut and must be used with caution. It deletes all the data to the right of the cursor in the line that you are typing in.

7. Ctrl + u

This is again a very powerful shortcut and must be used with caution. It deletes all the data to the left of the cursor in the line that you are typing in. Remember that once you run this shortcut you can not get back the text that you have typed.

---
Related Articles at Simple Help:


Some useful Linux bash tricks - Simple Help

by Ben Pike