System Admin  «Prev 

Obtaining and using root privileges

  1. Log in using root as the login name.
  2. Type your system’s root password.
  3. Notice that the command prompt is #. This type of prompt indicates root privileges. Using a console login as root is not recommended. It is too tempting to keep working as root when you log in from the console. Log out of the system by typing logout.
  4. The standard way to obtain root privileges is to assert them using the su command. You can use this command to “become” any user, but its main purpose is in asserting root privileges. Now, log in again, this time using the user1 account.
  5. Now type su to assert root privileges and enter the root password.
  6. The su command starts a subshell that has root privileges. The prompt changes automatically as a signal (and a warning) that this shell has extra privileges. Now, test your root privileges. Go to the /etc directory by typing cd /etc.
  7. Create a new file by typing touch roottest. The touch command creates an empty text file.
  8. Now, let us perform a specific task that requires root privileges. Delete this file by typing rm roottest.
  9. Confirm that you want to remove the roottest file by typing y.
  10. After completing tasks that require root privileges, you should surrender the root subshell. Type exit to exit this subshell.
  11. Notice that the prompt changed again, indicating that you are a normal user. Sometimes you will need to move back and forth between your regular shell and a root subshell. You can temporarily suspend a subshell with the suspend command. You can then move back to a suspended shell using the fg command. Let us see how this is done. Type the su command to obtain root privileges, then enter the root password.
  12. You are now back in a subshell that has root privileges. Type suspend to suspend the subshell with root permissions temporarily and return to the shell with normal user privileges.
  13. Type fg to resume the subshell with root privileges.
  14. Return to the shell with normal user privileges by typing suspend.
  15. Now that you are a normal user again, go to the /etc folder by typing cd /etc.
  16. Use touch to create a new file named roottest.
  17. You can not create this file because you do not have root permissions. Now, type fg to return to the root subshell.
  18. Type exit to close the root subshell.
  19. Close your normal user session by typing logout.