How to Add User to Sudoers in Ubuntu 26.04

Ubuntu is a popular, open-source Linux operating system that is based on the Debian architecture and known for its user-friendly interface. It is developed and maintained by Canonical Ltd., which provides regular updates and a highly secure environment for desktops, servers, and cloud computing. The name comes from a South African philosophy meaning “humanity towards others,” reflecting the project’s commitment to sharing free and accessible software with the world. In a Linux environment, there is a default user known as root, which possesses the highest level of authority in the system. Therefore, when you install Ubuntu desktop, for instance, your access is restricted since you are not utilizing root as the default user. In this article, we will show you how to add user to sudoers in Ubuntu 26.04.

The word root also has several additional meanings when combined with other terms, and this is one of the sources of confusion for people who are new to using GNU/Linux-based operating systems.

Prerequisites

  • An Ubuntu 26.04 VPS
  • SSH root access or a regular system user with sudo privileges

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 Access

In Linux, root is the name of the system administrator account. It holds absolute control over the entire operating system, with the power to modify any file, manage hardware, and override any security restrictions. To edit system configuration files, install new software, add user accounts, or undertake any tasks beyond your home directory, you need root access.

The root account is the most powerful user account in the system. It has unrestricted access and can modify anything — files, settings, installed software, system configurations — and it can grant or revoke permissions for any user or process. Regular (non-root) users do not have these broad administrative capabilities.

The root user is automatically a member of the root group, but being in the root group does not automatically grant the same superuser powers. Membership in the root group only provides privileges when:

  • Specific files or directories are group-owned by root and have group permissions set (e.g., read/write/execute for group), or
  • Additional mechanisms (most commonly sudo) have been explicitly configured to allow users in the root group (or other groups such as wheel, sudo, admin…) to elevate their privileges.

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.

Step 1. Update the System

Let’s log in to your Ubuntu 26.04 VPS through SSH as a root user or as a regular user with sudo privileges.

ssh root@IP_Address -p Port_number

Replace “root” with a user that has sudo privileges. Additionally, replace “IP_Address” and “Port_Number” with your server’s respective IP address and SSH port number. Next, let’s make sure that we’re on Ubuntu 26.04. You can check whether you have the correct Ubuntu version installed on your server with the following command:

# lsb_release -a

You should get this output:

No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu Resolute Raccoon 
Release:    26.04
Codename:    resolute

Step 2. Add a System User

Let’s create a new system user called ‘master’, run this command:

# adduser master

It will prompt you to create a password.

info: Adding user `master' ...
info: Selecting UID/GID from range 1000 to 59999 ...
info: Adding new group `master' (1001) ...
info: Adding new user `master' (1001) with group `master (1001)' ...
info: Creating home directory `/home/master' ...
info: Copying files from `/etc/skel' ...
New password: 
Retype new password: 
passwd: password updated successfully
Changing the user information for master
Enter the new value, or press ENTER for the default
    Full Name []: Administrator
    Room Number []: 
    Work Phone []: 
    Home Phone []: 
    Other []: 
Is the information correct? [Y/n] y
info: Adding new user `master' to supplemental / extra groups `users' ...
info: Adding user `master' to group `users' ...

Make sure to use a strong password when prompted.

Step 3. Add User to Sudoer

The next step in how to add user to sudoers in Ubuntu 26.04 is to understand that on Ubuntu systems, administrative privileges are typically granted by adding users to the sudo group. This is the standard and recommended way on modern Ubuntu releases (since around 12.04 onward, and still true in the latest versions). To give a regular user full sudo access (i.e., the ability to run commands as root with sudo), add them to the sudo group using one of these commands:

# usermod -aG sudo master

or

# gpasswd --add master sudo

Sudo Privileges

Replace master in the examples below with the actual username you want to grant privileges to (e.g. johndoe, sarah, adminuser, etc.). When using the usermod command, always include the -a flag. Without -a, the command replaces the user’s entire group list with just the sudo group — removing them from all other groups (including their primary group, users, adm, etc.).

Please bear in mind that granting sudo access is effectively the same as giving that user full root-level control over the system. They will be able to:

  • read, modify, or delete any file
  • install/remove software
  • change system settings
  • view sensitive logs and passwords (if they know how)

Only give sudo privileges to trusted individuals who genuinely need to perform administrative tasks.

Besides using one of the commands above, you can also use visudo to add users to the sudo group. Simply run the command below.

# visudo

Scroll down, then append this line below

master ALL=(ALL) NOPASSWD:ALL

No Password

Save the file, but before doing so, make sure to replace “master” with an existing system user on your Ubuntu 26.04. You can add the NOPASSWD: tag to allow specific commands (or all commands) to run via sudo without prompting for the user’s password. This is convenient for scripts, automation (e.g., cron jobs, Ansible playbooks), or headless servers, but it significantly reduces security — anyone who gains access to that account can immediately execute privileged commands without any authentication.

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:

master ALL=(ALL) NOPASSWD:/bin/ls,/bin/mkdir

Instead of editing the main /etc/sudoers file with visudo, a cleaner, more maintainable, and safer approach is to create a separate configuration file in the /etc/sudoers.d/ directory.

Ubuntu (and most modern Debian-based systems) automatically includes all files from this directory (as long as they follow naming rules and have correct permissions).

This keeps your main /etc/sudoers file untouched and makes it easy to enable/disable or remove custom rules without risking syntax errors in the primary file.

# echo "master ALL=(ALL) NOPASSWD:ALL" | tee /etc/sudoers.d/master

To check your new sudoer permission, you can run this command below as the sudoer:

sudo -l

The command above will print you this message:

Matching Defaults entries for master on ubuntu26:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty

User master may run the following commands on ubuntu26:
    (ALL : ALL) ALL

Wrap Up

That’s it all! You have just learned how to add user to sudoers in Ubuntu 26.04.

If you want to have a VPS with high-end hardware at an affordable price, look no further – our VPS hosting plans will let you host any software you want with dedicated resources.

Thanks for reading this tutorial – please share it with your peers if you found this guide helpful. You can also leave a comment if you liked the post or if you have any suggestions or concerns.

Leave a Comment