Ubuntu Basic Terminal commands !!


Example

(read as bangbang) is a shortcut to repeat the last command entered in console. It is especially useful to run previous command with some changes

adduser tom

adduser: Only root may add a user or group to the system.

Oh snap, what now? Well you could retype the command with sudo in front or you could try

sudo !!

equivalent to sudo "previous command entered"

This is especially useful if the command you just typed is especially long.

It can also be used to change a part of previous commands

cd path/to/wrong/directory

With

!!:s/wrong/right/

Will do

cd path/to/right/directory