Tag Archives: bash

Bash Tip #1

Often when operating on the commandline you may want to re-execute something with elevated privileges. There is a shorthand way to do this rather than either cutting and pasting or retyping the line.

mike@mike-P35C-DX3R:~$ updatedb
updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db'
mike@mike-P35C-DX3R:~$ sudo !!
sudo updatedb

The first updatedb command needs to be ran as root, initially I forgot the sudo so it couldn’t update the database. Running it again with !! meant that I didn’t have to retype the whole command… Obviously this is more impressive with longer lines…