Ubuntu is built based on Debian architecture. As one of the most popular Linux distributions among beginners and experienced users, Ubuntu emphasizes accessibility and ease of use. This Linux distribution is available both for desktops and servers. The default user, called root, has the highest power in a Linux system. Ubuntu limits your access when you install it on a desktop because you do not use root as the default user. This article will take you through how to add user to Root Group. Let’s get into it.
The word root has several additional meanings when combined with other terms, which can be a source of confusion for people who are new to using GNU/Linux-based operating systems.
Conventions
# – given commands should be executed with root privileges either directly as a root user or by use of sudo command
$ – given commands should be executed as a regular user
root directory
root directory or root directory/folder is the top-level directory on the Linux operating system. This directory is the main directory where all other directories are located. You write the root directory as /, otherwise called “slash.” We call directories in / or another directory subdirectories.
/root
We read /root as “slash root”. On Unix-based systems like Linux, each user has their own home directory. The home directory for regular users or normal users is /home. For example, the home directory of user ‘master’ is /home/master. Meanwhile, the subdirectory, which is the home directory for the root user is /root. This directory contains files and all standard/default configurations owned by the root user.
Root access
The root user/account on a system holds root privileges The “root” user account on a Linux system holds full administrative control over all aspects of the system. To edit system configuration files, install new software, add user accounts, or undertake any tasks beyond your home directory, it is necessary to have root access.
The root account is the most privileged account and has the highest power, including its ability to modify the system as desired and also allow or revoke access permissions or access rights. For regular users, these abilities are not available.
Root user is a member of root group, but the root group does not bring any inherent powers or privileges like root user. This means that the permissions you get from group root are because of group permissions on files in the root group or because of things like sudo that may be configured to give additional permissions.
If you want to add a user to have root privileges, it is highly recommended to add the user to the wheel or sudo group instead.
# usermod -aG sudo username
or
# gpasswd --add username sudo
Make sure to replace ‘username’ with the actual username on your Ubuntu system. Also, when running usermod command, make sure to use -a as the default option. If you don’t add the -a option in the usermod command above, that user is removed from all groups it was already a member and will be only a member of sudo group.
Remember that providing a user with sudo privileges essentially allows them root access. Trusted users who need higher permissions to run administrative tasks should have this level of access.
Beside using one of the commands above, you can also use visudo to add users to sudo group. Simply run this command below.
# visudo
Scroll down then append this line below
username ALL=(ALL) NOPASSWD:ALL
Save the file, but make sure to replace “username” with an existing system user on your Ubuntu 24.04. The NOPASSWD tag can be utilized to allow certain commands to be executed without prompting for the user’s password, which can be beneficial for automation like cronjobs but may increase security vulnerabilities.
Another example is to allow a user to run only certain commands through sudo. For example, to allow only the mkdir and rmdir commands, you would use:
username ALL=(ALL) NOPASSWD:/bin/ls,/bin/mkdir
Instead of running the visudo command above, you can also create a new file under the /etc/sudoers.d directory. Add the same rules that you added to the sudoers file:
# echo "username ALL=(ALL) NOPASSWD:ALL" | tee /etc/sudoers.d/username
This technique simplifies the administration of sudo privileges. The exact name of the file is not essential; however, it is generally advisable to name the file according to the username.
That’s it! You have learned how to add user to root group, which you should avoid. Instead, use visudo or usermod or gpasswd command to add users to sudoers and get root privileges. If you would still prefer not to do this yourself, take a look at our server management support plans and we’ll do it for you.