Bash interesting shortcuts and others

Hi guys,

I would like to share with you some bash shortcuts to save your time :slight_smile:

Copy from terminal : Ctrl + Shift + C
Paste to terminal : Ctrl + Shift + V
Stop a running command : Ctrl + C 

Ok lets start with better things now :slight_smile:

cd without argument takes you to your home directory :

the ~ represents your home directory, use it if you are working on machines you don't have the regular user name :

^old^new will replace the word 'old' by the word 'new' in your previous command, and run it again :

You are asking yourself why this ids are present in front of all your commands once you run the history command ?


Its one of the most importent bash feature !
(we are calling it bang)
in order to run one of the commands you already have run and has a ID, run the commandID with ! at the beggining :

!2009 will run again the command id 2009 - clear my side

Run faster typing your command :
Pressing Ctrl at the same time than your are moving with left and right arrow, you will jump to the previous word :

Ctrl + A will lead you to the beggining of the command (if you forgot a prefix in your command like 'sudo' to run your command as superuser or 'cat' in front of a text file

Lazy to make ctrl + A when you forgot a prefix of your command, no worries, the bash is with you !
run a command with !! (bang bang) in front will prefix the command with this additional word :


This works also with all the other commands (cat, nano, ...)

Repeat the last argument of the previous command :
The shortcut alt + . will insert into actual command the last argument of the previous command :

Auto completion is the most powerfull tool you have in your hands.
start writing your command and next start bombarding with tab key will most probably make you win a lot of time !

Inverted line order inside a file ? cat command have a good friend that works a bit different : tac

the yes command will automaticly answer yes to all questions in a command :

Don't hesitate to share other things you know !

Edit : I found this interesting post about auto completion :

1 Like

I like Ctrl + l to clear and Ctrl + d to close terminal.

2 Likes