You have to be logged in as root to perform the system administration tasks. The root user is the super user and the only account with all the privileges needed to do anything in the system.
If you are logged in as a normal user and need to become root, type the following command at a terminal window or console:
Then enter the root password in response to the prompt. From this point on, you’re root. Do whatever you have to do. To return back to your usual self, type:
It’s that easy to switch between being a normal user and root.
You should always type su - to become root rather than typing su. The su - command changes the environment to root’s default environment settings whereas su alone retains the current user’s environment, which may contain unsafe settings for environment variables.
If you use any of Red Hat’s GUI utilities to perform a system administration chore, it’s even easier. Typically, the utility pops up a dialog box that prompts you for the root password (see Figure 12-1). Just type the root password and press Enter. The GUI utility should then start. If you don’t want to use the utility, click Cancel.
To perform system administration tasks, you have to know the root password. What happens if you forget the root password? There is a way to recover from a forgotten root password. Just reboot the PC and you can reset the root password. Simply follow these steps:
Reboot the PC (select Reboot as you log out of the GUI screen) or power up as usual. Soon, you see the graphical GRUB screen with the names of operating systems you can boot. (If you have a GRUB password, press p and enter the GRUB password now.)
Press a (just the letter “a”). GRUB prompts you for commands to add to its default boot command.
Press the spacebar, type the following word, and then press Enter:
This causes Linux to start up as usual, but run in a single-user mode that does not require you to log in. After Linux starts, you see the following command-line prompt:
Use the passwd command to change the root password as follows:
sh-2.05b# passwd Changing password for user root. New password: (type the new root password)
Type the new root password that you want to use (it won’t appear onscreen), and then press Enter. Linux asks for the password again, like this:
Retype new password: (retype the new root password)
Type the password again, and press Enter. If you enter the same password both times, the passwd command changes the password and displays the following message:
passwd: all authentication tokens updated successfully
Now, type exit or reboot to reboot the PC. After Linux starts, it displays the familiar login screen. Now, you should be able to log in as root with the new password.
Make sure that your Red Hat Linux PC is physically secure. As this procedure shows, anyone who can physically access your Red Hat Linux PC can simply reboot, set a new root password, and do whatever they want with the system. Having a password for the GRUB bootloader can provide an extra level of protection.