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

Greece is having a Big Tech moment

https://www.youtube.com/watch?v=byQTI28FW_0 Greece’s Prime Minister Kyriakos Mitsotakis has an inside look at how the country is positioning itself as a...

Bitcoin Fever Grips Web Users as Google Trends Data Shows Interest Climbing

Bitcoin’s price has continued its upward trend, and Google Trends data reveals intensifying interest in the leading crypto...

Bitcoin Bull Score Jumps to 80 as Spot Demand Fuels Optimism

After months of price malaise, Bitcoin (BTC) is roaring back, having climbed past $103,000 today and signaling a...

Mythical Games Surpasses $650M in Transactions

Web3 game developer Mythical Games has announced it has surpassed $650 million in total transaction volume across its...

Advertisement

XRP Metric Jumps 200% — Here’s What It Means for Price

Technical and fundamental indicators support XRP’s bullish momentum, as more than 825 million XRP transacted between accounts.  An analyst...

Zerebro founder Jeffy Yu faked his suicide — found alive in flip-flops

Zerebro co-founder Jeffy Yu has been found alive after staging his suicide to promote the launch of his...

Must read

Greece is having a Big Tech moment

https://www.youtube.com/watch?v=byQTI28FW_0 Greece’s Prime Minister Kyriakos Mitsotakis has an inside...

Bitcoin Fever Grips Web Users as Google Trends Data Shows Interest Climbing

Bitcoin’s price has continued its upward trend, and...

You might also likeRELATED
Recommended to you