


"!!" is a history expansion of the previous command (in bash and csh). It is not always valid to prefix sudo textually to the previous command, but it does work in this case:mahjongg wrote:the actual command given was sudo "do nothing !!"
Code: Select all
pi@tau ~ $ make me a sandwich
what? make it yourself
pi@tau ~ $ sudo !!
sudo make me a sandwich
okay
pi@tau ~ $ cat Makefile
me a:
@:
sandwich:
@test "`id -u`" -eq 0 && echo "okay" || echo "what? make it yourself"

Code: Select all
shift@Shift-PC ~ $ whoami
shift
shift@Shift-PC ~ $ history
*list of commands you ran before*
507 whoami
508 history
shift@Shift-PC ~ $ !507
whoami
shift
shift@Shift-PC ~ $ !who
whoami
shift
shift@Shift-PC ~ $ sudo !who
sudo whoami
root
shift@Shift-PC ~ $ !who --version
whoami --version
whoami (GNU coreutils) 8.21
Packaged by Gentoo (8.21 (p1.0))
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

ah, never seen that one, but without the double bang ("!!") it is indeed a bit more logical.scruss wrote:Well played, jojopi!
The linked image is trivial edit of the XKCD original: http://xkcd.com/149/
Code: Select all
login: root
password: XXXXXXXX
Welcome to the Raspberry Pi
# Do what I command
Yes master.
#