When you’re installing your new Linux system, you very often need to launch commands as root. The right way to do it in the console is:

$ su -

After entering the password, you’ll be root. When you’re done with the root commands, just type exit.
Now, if you just need to type ONE command as root, this is pretty boring : first, su -, then your command, then exit. Remember, Linux is about efficiency! So you can use the sudo command to achieve that in only one step. Furthermore, you can even avoid having to enter a password (this is not a recommended setup, but this is possible). The whole process shifts from 1 minute to 5 seconds.

First, login as root (this will be the last time you’ll have to do it the long way!):

$ su -

After the password is entered, edit the /etc/sudoers file with visudo. Then, add a line at the bottom. If you want to use sudo without a password for some users (we’ll set which ones later), add this:


Note that it obviously is a security issue. The users pertaining to the “wheel” group (see below), once logged, will have basically the same rights that root without entering root’s password.

If you want to use sudo with a password:

%wheel ALL=(ALL) ALL

Users in the “wheel” group will have to enter their own password each time they use sudo (not root’s password). Note that by default, sudo remembers your authentication for several minutes, which means you won’t have to enter your password each time if you’re using it more than once in a row.

Now, you have to add the users you trust (only yourself ? :p) to the wheel group. You can use the GUI for that, found in your window manager menu (the command is system-config-users). Or, if you prefer, the command line:

# usermod -a -G wheel myusername

You’ll have to logout/login for the changes to be applied.