Becoming the root user

In order to perform administrative tasks you will have to use the superuser account, which is also known as the root account. This account is the most powerful one on your computer -- it can manipulate any file and access any device, regardless of the file ownership or permissions. In fact, in some ways it is too powerful -- many security exploits work by obtaining access to the root account. (In fact, there exist initiatives such as SELinux to reduce the power of the root account.) Because the root account is so powerful you do not want to use it for your day-to-day work, and you should take precautions to keep your root password safe and secure.

On the one hand, you do not want to log in using the root account. On the other, in order to make administrative changes you will have to operate as the root user. Some programs (such as aptitude) prompt you for the root password when it is time to do adminstrative tasks. Other programs and commands must be run from the root account. This section explains how to do this.

There are more mechanisms for running commands as root than are explained here. One of the most popular is a command called sudo. If you want to keep logs of the actions perfomed using the root account, or if many people handle the system administration of your computer, you may want to investigate this command.

Using su to change your identity

The su command is used to change users. To use it, type:

    
    su - 
    
    

and enter the root password when prompted. (You should have received this password when you got your computer.)

This will change the working directory to /root (which is the home directory of the superuser account). If you wish to stay in the current directory after changing identities, type

    
    su 
    
    

without the dash. There are some subtle differences between these two commands, but usually either will work for carrying out administrative tasks.

After becoming the root user you should find that your command prompt ends with a hash:

    
    wclp-box:~# 
    
    

Any commands you type will be run as the root user. To revert your identity out of root, type exit.

In fact, you can change your identity to any other user using su. For example, to become user bill, you could type

    
    su - bill
    
    

and then enter in the password for bill .

Running graphical utilities as root

Although most administrative commands are text-based, a few (such as printtool) are graphical. You also may want to run nedit as the root user to edit configuration files. If you try running these applications after changing your identity with su, you will get the following message:

 
    Xlib: connection to ":0.0" refused by server
    Xlib: Client is not authorized to connect to Server
    rxvt: can't open display :0
    

In order to launch graphical apps, you need to set an environment variable called XAUTHORITY. This gives the root account ``permission'' to show graphical applications on your screen, even though you did not log in as the root user. Say that your usual account is called linuxuser. Then you would type the following at the root prompt to enable graphical applications:

    
    export XAUTHORITY=/home/linuxuser/.Xauthority 
    
    

After running this command, you should be able to launch graphical applications. For example, to launch printtool, type:

    
    printtool &