Page 1 of 1
power of sudo !!!
Posted: Sat Mar 29, 2014 1:10 pm
by ric96
Re: power of sudo !!!
Posted: Sat Mar 29, 2014 1:34 pm
by GTR2Fan
Very good!

Re: power of sudo !!!
Posted: Sat Mar 29, 2014 1:53 pm
by mahjongg
lol.
but actually the actual command given was sudo "do nothing !!" , so its quite reasonable to agree with that.
a sudo "make me a sandwich" could result in a different response!

Re: power of sudo !!!
Posted: Sat Mar 29, 2014 2:19 pm
by jojopi
mahjongg wrote:the actual command given was sudo "do nothing !!"
"!!" 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:
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"
Re: power of sudo !!!
Posted: Sat Mar 29, 2014 2:33 pm
by mahjongg
ah, i was wondering if the !! had any special meaning!
you learn something every day.
I wonder of the maker of the cartoon was aware of it?
Although it resembles it, Its not an actual xkcd drawing is it?
if it is then I guess the "double bang" is no coincidence!
thanks!
Re: power of sudo !!!
Posted: Sat Mar 29, 2014 2:33 pm
by scruss
Well played, jojopi!
The linked image is trivial edit of the XKCD original:
http://xkcd.com/149/
Re: power of sudo !!!
Posted: Sat Mar 29, 2014 3:15 pm
by ShiftPlusOne
Just for the hell of it, a few semi-related tips:
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.
This is handy if you forgot some long command you typed. You can use history and ! to find and run it again. If you remember the start of it ! can be used to complete the rest of it and you can also run it as root by adding sudo before it. Or, as in the last case, you can use it to add parameters without typing the whole thing out again. If you're using gcc and don't need makefiles yet and you've already ran commands to compile, run and clean your program, you can use !gcc, !./and !rm too.
Re: power of sudo !!!
Posted: Sun Mar 30, 2014 2:08 am
by mahjongg
scruss wrote:Well played, jojopi!
The linked image is trivial edit of the XKCD original:
http://xkcd.com/149/
ah, never seen that one, but without the double bang ("!!") it is indeed a bit more logical.
which begs the question if the modifier of the cartoon did know that "!!" would expand to the last given command.....
i am guessing that its still simply coincidental....
Re: power of sudo !!!
Posted: Sun Mar 30, 2014 2:29 am
by toxibunny
Nah, that was deliberate. Nice job, too. Nerd humour at it's finest!
Re: power of sudo !!!
Posted: Sun Mar 30, 2014 8:07 am
by Richard-TX
I do it this way
Code: Select all
login: root
password: XXXXXXXX
Welcome to the Raspberry Pi
# Do what I command
Yes master.
#
no discussion, mother-may-i, or any other nonsense. It is just done
Re: power of sudo !!!
Posted: Mon Mar 31, 2014 11:40 pm
by mahjongg
lol.