Tech and AIHow to Quickly Give Users sudo Privileges in Linux

How to Quickly Give Users sudo Privileges in Linux

-


How many times have you created a new user on a Linux machine, only to find out that the new user doesn’t 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 every user on your system to have admin privileges. However, users who want to enjoy admin rights must be able to use the sudo command.

SEE: Debian vs Ubuntu: Which Linux Distro Fits Your Needs Best? (TechRepublic)

How to give users sudo privileges

Most modern Linux distributions have a user group that grants sudo privileges simply by being a member of that group. While sudo configurations allow individual accounts to have sudo privileges, this is not encouraged because it leads to user management headaches, especially if a user ID is changed or if that user’s account is removed or deactivated.

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

sudo less /etc/sudoers

In Fedora and Red Hat, this group is usually the wheel 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 all members of the admin group have full sudo privileges. To add your user to the admin group, you would 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 you were using Fedora or a Red Hat-based distribution, you would use the wheel group instead:

sudo usermod -a -G wheel USERNAME

Note that the user will continue to have sudo privileges as long as that user has this group assignment. To revoke sudo privileges, you will need to remove that user from that group.

SEE: Top Commands Linux Admins Need to Know (TechRepublic Premium)

Use with caution

You do not want to add every user to the sudoers file or the admin group. Use this with caution — otherwise, you risk jeopardizing system security. But with care, you can easily manage what your users can and cannot do.

Do more with sudo privileges

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

In addition, you’ll want to make administration easier by combining multiple commands into a single bash prompt.

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



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest news

Beware! North Korean Hackers Target Mac Users in a Very Creative Way

SentinelLabs, the research and threat intelligence arm of cybersecurity firm SentinelOne, has delved into a new and sophisticated...

Trump’s Defiance of TikTok Ban Prompted Immunity Promises to 10 Tech Companies

US attorney general Pam Bondi has told at least 10 tech companies, including Apple, Microsoft, Amazon, and Google,...

Rising Cardano price has formed a risky pattern

Cardano price rose for the second...

Slate Auto drops ‘under $20,000’ pricing after Trump administration ends federal EV tax credit

Slate Auto, the electric vehicle startup backed by Jeff Bezos, has stopped promoting that its upcoming pickup truck will start...

Advertisement

North Korean Hacking Groups Employ New Methods to Target Web3 Companies

North Korean hacking groups are developing new methods to target Web3 companies, including some aimed at infecting Apple...

Must read

Beware! North Korean Hackers Target Mac Users in a Very Creative Way

SentinelLabs, the research and threat intelligence arm of...

You might also likeRELATED
Recommended to you