sudo !!

sudo is a method of executing programs on a Linux/Unix machine with the permissions of a different user (usually root). sudo enabled systems generally have the root account disabled, which means it is easy to forget to elevate the privileges of root programs.

sudo !! solves this by executing the previous command with root privileges. This doesn't make much difference for short commands such as shutdown, but for longer commands, this can save a few seconds.

user@host:~$ shutdown +1
shutdown: Need to be root
host@host:~$ sudo !!
sudo shutdown +1
Broadcast message from user@host
(/dev/pts/0) at 21:44 ...
The system is going down for maintenance in 1 minute!

Leave a Reply