It is important to log in with your user account instead of as the
root user when performing day-to- day tasks. Some of the graphical
administration tools will prompt you for the root password if you try to run
them as a regular user. But, what if you are logged in as a user and need to
perform an operation only the root user can do? It would be time consuming to
close all your open windows, log out of the graphical desktop, log back in as
root, execute root-only commands, log out again, and then log back in with your
user account.
Instead, you can temporarily start a terminal session as root. From
a shell prompt, execute the following command to temporarily become the root
user:
su
–
Notice the space and then a hyphen after the su
command. These are extremely important parts
of the command. Without it, you have root privileges but you don’t inherit any of
the environment variables of the root user, including the important PATH
variable previously discussed. Without the
proper PATH that includes /sbin/ and /usr/sbin/, it will
appear as if many administrative commands don’t exist. After executing the su
- command, you will be prompted to enter the
root password before being granted access. If the correct root password is
entered, you will notice that the prompt changes to show that the root user is
the currently logged-in user.
When you no longer need to be root, type the exit
command and then press Enter to return to your user
shell.
0 comments:
Post a Comment