Using the su Command


Using the su Command

You already know that many tasks in Linux can be performed only by the root user. Most of the tasks you perform in this chapter fall into this category. It can often be inconvenient to have to log out and log back in as the root user simply to perform an administration task or two.

Fortunately, Linux provides a command that can be used to temporarily perform tasks as the root user. In its basic form, this command, su, is called without arguments. When you call su, you are prompted for the root password. If you can enter the password correctly, a subshell that is owned by the root user starts, and the shell prompt is displayed. Any commands you enter in the subshell work as though you were logged in as root. After you finish performing administration tasks, enter exit to close the subshell and return to the normal user command prompt.

The following lines show a user using the su command to become the root user, issuing a typical administration command to change the password of a user (a command you learn about later in this chapter) and then exiting:

 [you@workstation20 ~]$ su Password: [root@workstation20 you]# passwd janeuser Changing password for user janeuser New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully [root@workstation20 you]# exit [you@workstation20 ~]$ 

Notes About Using the su Command

You know when you are working as the root user on a Fedora Core 4 system because the command prompt ends with a hash mark (#) instead of a dollar sign ($).

Remember to use the su command only when you need to perform an administration task that can't be performed as a normal user. Doing any real work as the root user is a dangerous proposition because Linux does exactly what root says, even if it is harmful to the system itself.




    SAMS Teach Yourself Red Hat(r) Fedora(tm) 4 Linux(r) All in One
    Cisco ASA and PIX Firewall Handbook
    ISBN: N/A
    EAN: 2147483647
    Year: 2006
    Pages: 311
    Authors: David Hucaby

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net