Last Updated: February 25, 2016
· abhikandoi2000

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

5 Responses
Add your response


This comic explains it best. (It's a modified version of the xkcd comic).

over 1 year ago ·
over 1 year ago ·

Thanks. :)

over 1 year ago ·
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 ·


over 1 year ago ·
Filed Under