Root user

From LQWiki
Jump to navigation Jump to search

In Linux, "root" is the default superuser that has access to all commands and files. The root user has the authority to change and access all file systems, access and modify all directories, to install or uninstall programs and make any and all system changes. The Linux system is based on the idea that only a fully-knowledgable system administrator will be performing root functions and, therefore, has no "undo" or system safety net for changes made by the root user. Because the root user has so many system-wide privileges (and because you can do irrepairable damage to your system with those privileges), it's not a good idea to log in as the root user for day-to-day system access. Also, if you're logged in as the root user and a hacker somehow gains access to your system, the hacker will automatically have those root privileges. This is another reason why logging in as the root user is discouraged.

Even though your regular, everyday user account may not have all of the same access as the root user account, you can invoke the authority of the root user as needed by making sure that your regular user account has "sudo" privileges. "Sudo" is the command that allows a regular user to become root for a specific function. By default, most Linux distributions will empower the first default user with sudo privileges. To become the root user in order to install software or make other system changes, open a terminal and type the following:

"sudo su"<enter>

The system will then prompt you for your user password. Once you've entered your password, you'll notice that the command prompt has changed from the "$" symbol to the "#" symbol and user command line will change from "user@linuxdistro:~$" to "root@linuxdistro:/home/user#". You can now install software or change the permissions to a file or perform whatever other system-altering fixes you might need. When you've completed these functions, simply type "exit" into the terminal screen and you'll see the user information and prompt change back to your regular user.

For those Linux distributions that do not automatically extend the "sudo" privileges to the default user, you will have been prompted for a root password during your installation. In this case, open a terminal and type "su"<enter>. You'll now be prompted for the root password that you set up during your installation. Once you've entered that root password, you'll now transform into the root user just as in the instance above.

To make sure that in the future your regular user account has "sudo" privileges, don't type "exit" at the end of your system maintenance. While still the root user in the terminal, type the following: "visudo"<enter>. This will open the "sudoers" file as an editable document. Scroll down to the line: "root ALL = (ALL) ALL" and change it to read: "user ALL = (ALL) ALL" except inserting your user name in the place of "user." Save and close the document and your regular user will now have the "sudo" privilege so that you can become root as needed.