There was a recent quora thread on common linux tricks and a discussion ensued on hacker news regarding the same. I just distilled some of the bash tricks from these discussions and have listed it.

<ctl> – Control key
<alt> – Alt key

1. Command reverse/history lookup
<ctl> + r and start typing the command. If there is any command in history that matches the text you have put in, it will be displayed.

2. Execute the most recent command in history.
!foo will execute the most recent command from your history that matches foo.

3. Some useful bash keyboard short cuts.
<ctl> + W – Kill the last word.
<ctl> + U – Kill the line.
<alt> + . – Cycles through previous arguments.
<alt> + * – Expands a glob.

3. Go back to the previous working directory.
cd –

Feel free to comment with your bag of tricks and I will update the post with them.

Advertisements