What is Root User in Linux? [A Complete Guide]

The root user is one of the most vital parts of the system administration of the Linux operating system. Moreover, this user can affect the whole system by performing any task. In a multiuser system, the root users control the activity of other users. In this article, I will demonstrate a complete overview of what is root user in Linux.

What is a Root User?

The root user is the super user or administrator who has full access to all the system files, directories, and commands of the Linux operating system. This user can do any task which can change the security and stability of the whole system.

Difference Between a Root User and a Non-Root User

A root user is a user having superpowers who can perform all the administrative tasks (i.e. package installing, user removing, accessing any files or directories, and many more) that can affect the whole system. On the other hand, a non-root user having limited privileges can not perform such administrative tasks that can affect the system.

How to Create a Root User?

In Linux, various ways are available to create a root user. Any user with root privileges can add a new root user in Linux from both the graphical user interface and the command line. Both of them are outlined below.

Method 01: Creating Root User from GUI

In the following section, I will create a root user from GUI(Graphical User Interface). To do so, follow the below procedures.

Steps to Follow >

➊ Find the view application button on the left corner of your home screen and left-click on it.Find the view application button on the left corner of your home screen.➋ After that type settings in the search bar, then the Settings application will appear. After that Click on the Settings application.Type settings in the search bar, then the Settings application will appear.➌ Then, type users on the search bar, by doing so, an option named Users will appear. Now, click on this Users option.Searching users in the settings applications.➍ Now, click on the Unlock option which is in the top right corner of the Users window.Click on the Unlock option.➎ It will open a new prompt to authenticate the current root user. You have to put the password of the current root user and then click on the Authenticate option.Put the password of the current root user.➏ After that, a new option named Add User.. will appear on the top right corner of the Users window. Click on the Add User.. option.Click on the Add User.. option.➐ Then, a new Add User prompt will appear. You have to click on the Administrator option and then fill up the all pieces of information like Full Name, Username, and Password. Then finally, click on the Add option.Providing the required information.

Output >

In the following image, you can see I have created a new root user named Thiago.A new root user named Thiago has been created.

Method 02: Creating a Root User from the Command Prompt

Here, I will create a root user from the command prompt. To do so, follow the below procedures.

Steps to Follow >

➊ Open the Ubuntu terminal.

➋ Then, type the following command then press ENTER button to create a new user named Donald.

sudo adduser donald

Adding user with the adduser command in linux.➌ After creating a user named donald, copy the following command in the terminal and then press ENTER to add the donald user to the sudo group.

sudo usermod -aG sudo donald

Adding the new user named donald to the sudo group.➍ To check the group of the new root user named donald, type the following command and press ENTER.

groups donald

Output >

The new user named donald belongs to the sudo group, this means that donald is a root user.The new user named donald belongs to the sudo group.

System Management Operations Exclusive to Root User

A root user in Linux can do all kinds of administrative tasks(i.e. package installing, user removing, accessing any files or directories and many more). In the following section, I have illustrated a few o the administrative tasks that only a root user can do.

Example 1: Installing Any Package in the System

Only root users in Linux can install/remove packages in the system. Here, I will install the nano package with the root user named donald. To achieve so, follow the below procedures.

Steps to Follow >

➊ At first open the ubuntu terminal and type the following command to switch the user to the new root user named donald.

su donald

Switching to the user named donald using the su command.➋ To check the current user, type the following command and press ENTER.

whoami

Checking the current user with the whoami command in Linux.➌ Then, copy the following command in the command prompt and press ENTER.

sudo apt install nano

Installing the nano package with the new root user.

Note: The sudo command can only be used by a root user in Linux. Since donald is a root user, it can readily use the sudo command.

Example 2: Changing Permission of a File

A root user can alter the permission of any file and directory. Here, I will switch my current user to donald who is a root user. Then, I will change the writing permission of the Music directory. To do the task, follow the procedures given below.

Steps to Follow >

➊ At first, open the Ubuntu terminal.

➋ Then, type the following commands to the terminal and then press ENTER to check the permission information of all the files and directories inside the current directory.

sudo ls -l

Listing detailed information of all the directories in the current directory.➌ Now, copy the following image to the terminal and then press ENTER to allow the writing permission of Music Directory for all(other, owner, and group).

sudo chmod a+w Music

Using the chmod command on the Music directory.➍ Then, type the following commands to the terminal and then press ENTER to check the permission information of all the files and directories inside the current directory.

sudo ls -l

Output >

The following image shows that as a root user (donald), I have altered the permission of the desired directory.

The root user named donald has altered the permission of the desired directory.

Example 3: Accessing Any File of the System

As a non-root user, you can not access the root or any other files. But as a root user, you can access the root or any other files. Here, I will first try to access the /root directory as the sdg user which is not a root user. Then, I will try to access the /root directory as the donald user who is a root user. To do so, follow the below procedures.

Steps to Follow >

➊ At first, open the Ubuntu terminal.

➋ After that, copy the following command on the terminal to switch the user to donald who is a root user.

su donald

➌ Next, tap the ENTER button.

➍ Then, type the following command on the command prompt to access the /root directory as the donald user who is a root user.

sudo ls /root

➎ Now, press the ENTER button.

Output >

The following image shows that the non-root user named sdg can not access the /root directory but the root user named donald can access the /root directory.The non-root user named sdg can not access the /root directory but the root user named donald can access the /root directory.

Conclusion

In this article, I have tried to sum up the utilities of the root user and showed some sample activities a root user can perform. By going through this article, you will gain the skill of creating a root user and performing some sample operations which only a root user can do.


Similar Readings

Rate this post
LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now
icon linux
Susmit Das Gupta

Hello everyone. I am Susmit Das Gupta, currently working as a Linux Content Developer Executive at SOFTEKO. I am a Mechanical Engineering graduate from Bangladesh University of Engineering and Technology. Besides my routine works, I find interest in going through new things, exploring new places, and capturing landscapes. Read Full Bio

Leave a Comment