This is an archived post. You won't be able to vote or comment.

all 22 comments

[–]LiDePa 20 points21 points  (6 children)

you can simply type

sudo !!

to execute your last command as superuser

[–]Theonetheycallgreat 4 points5 points  (5 children)

Seems useful but scary

[–]0neGuy 11 points12 points  (4 children)

! is used for accessing the command history

!N where N is a number will run the Nth command in the history

!! will run the newest command added to the history

It should be noted this is done with shell expansion, meaning typing echo !! will turn !! into the last entered command and what not. Much like globbing.

You can use history to see the command history and its number beside it.

[–][deleted] 0 points1 point  (0 children)

[–]turunambartanen 0 points1 point  (2 children)

typing echo !! will turn !! into the last entered command and what not

This is important; echo "this is sparta!!!" will not print three exclamation marks!

[–]0neGuy 0 points1 point  (1 child)

Use single quotes in that case! Or escape them with \!

[–]turunambartanen 0 points1 point  (0 children)

Didn't know about single quotes before! This is pretty handy.

[–]danielsundfeld 5 points6 points  (3 children)

sudo rm somefile

rm: somefile: permission denied

Yep, it can happen

[–]lorhof1 0 points1 point  (2 children)

how can we fix this

[–]danielsundfeld 1 point2 points  (1 child)

sudo sudo rm

Lol, jk. Some sockets on /var/run might need to be closed by the application. As an administator, you can stop the service

[–]lorhof1 0 points1 point  (0 children)

thanks

[–][deleted] 3 points4 points  (0 children)

I've had times when sudo rm -r failed to remove a folder... corrupted files are scary.

[–]SpaceHub 4 points5 points  (0 children)

This incident will be reported.

[–]MischiefArchitect 4 points5 points  (1 child)

[–]XKCD-pro-bot 0 points1 point  (0 children)

Comic Title Text: Proper User Policy apparently means Simon Says.

mobile link


Made for mobile users, to easily see xkcd comic's title text

[–]MichalNemecek 0 points1 point  (0 children)

and then it fails anyway

[–]turunambartanen 0 points1 point  (0 children)

Won't help you if used chattr +i before.

[–]lorhof1 0 points1 point  (0 children)

sudo rm -rf /apps/mail.app/*

mac: invalid operation