darkflib.github.io

Site Reliability Team Lead at News UK

View My GitHub Profile

30 November 2011

Bash Tip 1

by Mike

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.

[email protected]:~$ updatedb
updatedb: can not open a temporary file for '/var/lib/mlocate/mlocate.db'
[email protected]:~$ 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…

tags: