When working on shell commands, one thing that might happen quite a lot is to repeat some commands now and then, in many cases repeating the same command adding a missed sudo.
We all know about the history command that retrieves all previous commands executed, but it’s quite powerful to know the called bash history expansions.
- CTRL+R – this key combination will open the reverse-i-search. You can then write ssh and the previous command that includes ssh will appear. Press again CTRL+R and previous match will appear.
- !! – this will re-run previous command
- sudo !! – this will re-run previous command adding before the sudo
More information about the topic: