Using the su CommandYou 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 ~]$
|