sudo is a command-line UNIX utility that allows you to execute a command as another user (most likely, the superuser). Usually you’ll use it to execute a single command:
or to start a shell:
sudo is similar to the
su command – the
su command also allows you to become another user (most likely root). The difference is that
su requires you to type the other user’s password.
sudo allows you to use your own password. The file
/etc/sudoers tells the system who is allowed to do what using the
sudo command. In a multiuser environment, this has the benefit of allowing multiple users to become root (or other users) without giving them the root password. Then you can easily revoke root privileges from a user if you need to without affecting the other people who may need to become root.
That’s great, but on a single user machine it’s annoying to have to type your password each time you use
It’s easy to change your system to allow you to use
sudo without a password. Realize that this is a huge security risk. If someone gets access to a shell prompt on your computer after you’ve done this, they’ll have access to everything on it. Using
sudo they’ll be able to override all the security and copy, change or delete any file they want. I cannot recommend that you do this. But if you really want to, here’s how.
Become root and type this command at the shell prompt:
chmod +w /etc/sudoers
this will make
/etc/sudoers writable. On my Mac, it was read-only.
/etc/sudoers in your favorite text editor, and add a line to it that looks like this:
USERNAME ALL=(ALL) NOPASSWD: ALL
USERNAME with your short username (so in my case, my username is
johnromkey rather than
'John Romkey'). You can find your username with the
who command – but if you don’t already know what it is or who to find it, you probably shouldn’t be disabling passwords on
sudo in the first place.
This line tells
sudo that your account can use it to become any other user without giving a password. There are other ways to do this (in particular, there are ways to say that anyone in a particular UNIX group can become use
sudo without a password), but this is the simplest way to let a single user do this.
Once you’ve added that line, save the file. Now you’ll need to make it read-only again with this command:
chmod -w /etc/sudoers
If you’ve done this correctly,
sudo should no longer require you to enter a password.