Get updates via: rss | twitter | email

Forgot to enter sudo

Written by
Date: 2014-09-07 16:55:20 00:00

What to do when you write a long command, and realize that you forgot to write sudo.

Q. I keep forgetting about writing sudo in front of commands since I switched to Ubuntu from other Linux distribution, is there an easy way to repeat the command with sudo in front of it?

A. You only need to creat an alias, that will call the last command with the command sudo in front of it, and you don't need to type the whole command again.

Do something like this:

alias sorry='sudo $(history -p \!\!)'

Now, next time you run:

service postfix restart

And the server says:

-bash: service: command not found

Just run:


And it will ask for your password and complete the task