Root User

The root user is the account that by default has full access to all files and directories on a Linux operating system. It is also known as the superuser.

When you are logged in as root, the command prompt shows# instead of $ (if you are using bash) as a reminder that you are using the root account and to be careful which commands you type, as a mistyped command could erase essential files.
It is recommended not to sign in as root unless it is absolutely necessary and to logoff once you have completed the administration tasks.

How to become root user

Use the ‘su' command (substitute user). This is used to become another user and if used without specifying a username it will default to root. Use the ‘-‘ argument to make the shell a login shell which will make the environment similar to if the root account had logged on directly.

Example
[testuser@w3db.org ~]$ su - Password: [root@w3db.org ~]#

Using sudo

An alternative and more secure way of performing administration tasks is to use the sudo command, this allows an ordinary user to run a single command with root privileges. When running the sudo command, the system will prompt for the current users password before running the command as root. Not every user account has the ability to run the sudo command, the user must be in the sudoers file (/etc/sudoers).

To add a user to the sudoers file, use the visudo command to edit /etc/sudoers. You must be logged in as the root account to be able to do this.

visudo

Add the below line, replacing testuser with the name of the user account that you want to have sudo access.

testuser ALL=(ALL:ALL) ALL

Save and exit the file, you will now be able to run the sudo command as the user you specified.

Syntax
sudo [commandname]
Example
sudo visudo