Switching to Root User on Linux

Running your web hosting server will require many times to run commands as the root user. Many admins choose to block direct root logins, so first, you will need to log in as a normal user and then switch to the root user.

There are some web hosting companies that sell managed servers without root access. This is to prevent any issues you can accidentally cause logged in as root. So, take care when working as root 😉

To switch to the root user use the su – command. Enter the root password when asked.

[mab@localhost ~]$ su -
Password: 
[root@localhost ~]#

If you want to switch back to the initial user or to another user:

su - <username>

[root@localhost ~]# su - mab
[mab@localhost ~]$