Using sudo in Linux: a mini tutorial

How can users have root (administrative) privileges in Linux, Unix without knowing the root password? One of the best answers to this question is sudo. Users login using their username and password and issue administrative commands placing sudo in front of the commands, e.g. sudo rpm -Uvh *.rpm , to run the command which installs and updates programs in Linux (rpm). For more details see this introduction to sudo from its authors. To create the file which assign administrative privileges to users -- the sudoers file, please read the sudoers documentation page.

This mini-tutorial focuses on the easiest way a user can use the administrative privileges assigned to him/her by the sudoers file, without knowing the root password. This version is for Linux Fedora Core and Red Hat graphical environment. There is another version for other Linux, Unix environments.



Fedora Core and Red Hat require you to become root using sudo before X Windows starts. Most installations start by default in graphical mode, asking for username and password already in X Windows. This seems to prevent the use of sudo to have access to Fedora and Red Hat graphical tools requiring root privileges. The following procedure will guide you to solve this problem:

  1. log in Linux graphical mode as usual, answering your username and password
  2. open a terminal, shell window.
  3. at the bash shell prompt $ type sudo -v
  4. Linux will ask you for a password -- enter the password of your account
  5.    For the next 5 minutes it will not ask you for your password when you use sudo.
  6. after Linux returns the bash shell prompt $ type sudo su -
  7.   Since you already have root privileges, it will not ask you for the root password
  8. Linux will reply with something like [root@mislab01x root]#
    Linux accepts your login as root and gives you the root path. You are now ready to start X Windows as root!
  9. at the prompt # type startx -- :1 vt8    This will start another X Windows session with root privileges
  10. You can now use all graphical tools requiring root privileges.

This page is maintained by Al Bento who can be reached at abento@ubalt.edu This page was last updated on March 8, 2006. Although we will attempt to keep this information accurate, we can not guarantee the accuracy of the information provided.