When it comes to linux terminals I have been fortunate enough to have come across many tips and tricks from many of my mentors, colleagues and as well as the internet(Stack Overflow obviously).
The first one is my personal favourite and is one that everybody badly needs, have you ever run a command and then get the most common error that you do not have permission or you need to be root only to realise you haven’t used
sudo and then you end up either retyping the command like
sudo <your-command> or you press the up arrow and then keyboard shortcut home button and then type
sudo to end up with
sudo <your-command> What if you could just use sudo bang bang instead, a cooler and much efficient way to re-run immediate previous command but with modifications, in our context adding the sudo to the beginning.
Ex: When you run the below
1 ls /root
So, run the below command where
!! will append the previous run command.
1 sudo !!
Reverse lookup on history (commands that were run previously)
Ctrl+r and type parts of previously used command. For example, to get a previously run ssh command
Ctrl=r and start typing
1 (reverse-i-search)`ssh': ssh -i ~/.ssh/id_rsa email@example.com
Exit a session using exit command or shortcut Ctrl+d