How to Quickly Grant Users Sudo Privileges on Linux


How many times have you created a new user on a Linux machine, only to discover that the new user does not have sudo privileges?

Without the ability to use sudo, that user is limited in what they can do. This, of course, is by design, because you certainly don't want all users on your system to have administrator privileges. However, users who want to have administrator rights must be able to use the sudo command.

SEE: Debian vs Ubuntu: Which Linux distribution best suits your needs? (Technological Republic)

How to give users sudo privileges

Most modern Linux distributions have a user group that grants sudo privileges simply for being a member of that group. While sudo configurations allow individual accounts to have sudo privileges, this is not recommended because it creates user management headaches, especially if a user ID is changed or that user's account is deleted or deactivated.

You can determine which group it is by looking at the /etc/sudoers archive. You can safely view the contents of this file using the command:

sudo less /etc/sudoers

On Fedora and Red Hat, this group is usually the wheels group:

## Allows people in group wheel to run all commands
%wheel   ALL=(ALL)         ALL

In Ubuntu and Kali, this group is usually the sudo group, not to be confused with the sudo command:

# Allow members of group sudo to execute any command
%sudo    ALL=(ALL:ALL)  ALL

This means that all members of the management group have full sudo privileges. To add your user to the administrators group, you must issue the command (as a user who already has full sudo privileges):

sudo usermod -a -G sudo USERNAME

Where USERNAME is the name of the user to be added. Once the user logs out and logs back in, they will now enjoy full sudo privileges. If I were using Fedora or a Red Hat-based distribution, I would use the caster group instead:

sudo usermod -a -G wheel USERNAME

Note that the user will still have sudo privileges while they have this group assignment. To revoke sudo privileges, you will need to remove that user from that group.

SEE: Top commands Linux administrators should know (TechRepublic Premium)

Use with caution

You don't want to add all users to the sudoers file or admin group. Use with caution; Otherwise, you risk compromising system security. But with care, you can easily manage what your users can and cannot do.

Do more with sudo privileges

With your new sudo privileges, you can add a new user to your Linux system, list system services, and search for files from the command line.

Additionally, you'll want to make administration easier by combining multiple commands into a single bash command prompt.

This article was originally published in August 2023. It was updated in January 2025 by Antony Peyton.

scroll to top