Most users on your Linux machines might be non-admins who use services and directories for various purposes. However, you might come into a situation when you need to “promote” one of those users to admin and give them sudo privileges.
How do you do that?
Once upon a time, it was required that you edit the sudoers file–which is still very much possible, but not necessary. There’s a much easier and more reliable method of promoting those standard users with sudo privileges. I’m going to show you how to do just that.
I’ll demonstrate on both Ubunutu- and Red Hat-based distributions, specifically, Ubuntu Server and AlmaLinux. You’ll be surprised how easy this is. It’s all about adding those users to the right group. Let’s first do this on Ubuntu Server.
SEE: Linux file and directory management commands (TechRepublic Premium)
How to give users sudo privileges on Ubuntu Server
Log in to the machine and add the user in question to the sudo group with the command:
sudo usermod -aG sudo USER
Where user is the name of the user.
Once this is complete, the user will need to log out and log back in for the changes to take effect.
How to give users sudo privileges on Red Hat-based distributions
On Red Hat-based distributions the group is wheel, so the command would be:
sudo usermod -aG wheel USER
Where user is the name of the user to be added. Again, have the user log out and log back in so the changes will take effect.
How to remove users from a group
If you want to remove a user from those groups, the command would be:
sudo gpasswd -d USER GROUP
Where USER is the user name and GROUP is the group in question.
And that’s all there is to it. You’ve officially promoted those standard users with sudo privileges. Just make sure you only do this with users you trust, or you could wind up with serious problems to deal with.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.
Subscribe to the Cybersecurity Insider Newsletter
Strengthen your organization's IT security defenses by keeping abreast of the latest cybersecurity news, solutions, and best practices. Delivered Tuesdays and Thursdays