Some of my fav unix/bash commands.
Awesome Bash shortcut I recently discovered allows you to quickly clear stuff from a bash command.
Ctrl + w #
Clears the last block of text in a command.
Say you’ve got something like:
git commit -m "Added some things here and changed some other things over there."
That’s a terrible commit message, you should rewrite that. Issue Ctrl+w
to get rid of the block of text to the left of the cursor.
Ctrl + r #
Allows you to search through your recent commands. Issue Ctrl+r
to open the query prompt, then simply enter your search.
Ctrl + l #
Clears all the shit in the bash window, leaving you a fresh screen. Also works in some interpreter prompts too, in Python for example.
Ctrl + z #
Ever started a long process without appending the ampersand &
? For example,
$ mysql.server start
Well instead of killing the process with Ctrl + c
, do Ctrl + z
. It will throw that process into the background and return you to the bash prompt, just as it would if you used &
in the first place. To fetch back the process, do
$ bg
Note, all output is still directed to the terminal stdout.
Lastly,
!! #
Is a link to the last command. Useful for if something requires super user privs, you can re-run the command by doing,
$ sudo !!