awombw
Last Updated: February 25, 2016
·
1.612K
· abhikandoi2000
B7b49831b9a1e3f260d412488bbda9f8

Little Known Terminal Command

Executed a command in the terminal just to find out that you don't have the required permissions. Maybe you have to execute the same command with a sudo before it.

Executing the following command

rm /etc/udev/rules.d/51-android.rules

without root permissions gives the following message

rm: remove write-protected regular file ‘/etc/udev/rules.d/51-android.rules’?

Now a common solution is to simply execute the same command with a sudo before it

sudo rm /etc/udev/rules.d/51-android.rules

but this requires a little effort, pressing the up arrow key, using the home key to reach the start of the command and then typing sudo

Well there is another smart way to do it. Simply type

sudo !!

and the previous command is executed using sudo.

This also works with other commands. Like you could simply watch the output of the previous command by typing

watch -n 0.1 !!

This can save a lot of your time as you shall see.

Say Thanks
Respond

5 Responses
Add your response

6745
Mug

This comic explains it best. http://img.gawkerassets.com/img/18fbly07jtb2gpng/ku-medium.png (It's a modified version of the xkcd comic).

over 1 year ago ·
6762
D54f65ad3ff9ee1c9c033a403d4b5f9f
over 1 year ago ·
6771
B7b49831b9a1e3f260d412488bbda9f8

Thanks. :)

over 1 year ago ·
6806
Regent twitter

This is one of my favorite terminal commands, mostly because I feel as if I am expressing a stern frustration whenever I use it.

No. You will run that command, Bash.

Side note: instead of the home key you can use ctrl+a to move the cursor to the beginning of the line. This is useful if you don't have a home key, or if you want to keep your hands on the home row. ctrl+e to move to the end of the line.

over 1 year ago ·
6817
2af4ea9bb6380b59d05d2b9b6d8112e9

sweat!

over 1 year ago ·
Filed Under