Elevating privileges
As an administrator of the RHEL server or desktop system, there will be times when root access will be required. The root
user or user ID 0
is the local administrator on the system. Although it's possible to log in to the system as a root
user, as with most systems, it's preferred that root
access is gained as required. There are two mechanisms that can be used:
- The substitute user or the
su
command - Using the
sudo
command
First, we will look at the su
command.
The su command
When a user issues the su
command without specifying a username, they will be prompted for the root password. If authentication is successful, they will be presented with a root shell. The following are the valid mechanisms to gain root privileges with su
:
su -l
: This presents a full login shell for root; all environment variables are set for root. The working directory of a user is changed to become the home directory of the root user, which is usually/root
.su
: This is the same assu -l
.su...