sudo is different from su

September 21st, 2006 mysurface Posted in Admin, source, sudo | Hits: 69914 | 2 Comments »

Some of the distro uses sudo to gaim access to run root privilage commands. But some of the distro do not include sudo by default such as FC5. To run some root privilage programs, you need to login as root by using su and gives root password.

Sometimes admin would not like to give away the root password to the user but admin still wants to allow certain root access to specific users. With that sudo comes to help.

To allow sudo for a certain user, you need to edit /etc/sudoers by typing


Visudo will actually open /etc/sudoers for edit. Add in the line like this.

# User privilege specification
root      ALL=(ALL) ALL
foobar  ALL=(ALL)  ALL

Adding foobar to allow it access ALL root privilage commands and files.

By using that, user foobar can access root privilage commands easily such as iptables by doing this

sudo iptables -L

By type your own user password, you can access root privilage commands. But sometimes certain distro do not include certain path for user, such as /sbin, which contains a lots of root privilage commands. Therefore you cannot sudo straight forward. But there are two solution for that.

  1. export /sbin to path
  2. sudo login to root user.

To export /sbin into path, the best way is edit .bashrc at your home directory, add in the line

export PATH=$PATH:/sbin

After that source your .bashrc and try again.

source .bashrc

Login as root with sudo is more simple,

sudo su -


sudo -i

Somehow certain distro do not support sudo -i.

User always need to enter user password when you trigger sudo to access root privilage commands, that is somehow irritating. To overcalm this, you can allows the user by running sudo without need to type password, edit /etc/sudoers, modify the foobar line to become this


Enjoy (:

2 Responses to “sudo is different from su”

  1. […] Don’t take the risk to enable root access, unless you are sure what are you doing. If you need root access, consider to use sudo.                              […]

  2. […] Sudo and su are not the same, check out more from here. […]

Leave a Reply