How to Grant Admin Privileges to a User in Linux

Need to get admin privileges in Linux, but not sure how? Today we’ll discuss how to quickly grant administrative rights to a specific user on Ubuntu and Arch Linux.

Why Do I Need Admin Privileges?

While using a Linux system, when you try to attempt any kind of administrative task, like installing or removing software, you might get an error saying you don’t have the right permissions. This can be frustrating at times, but getting admin rights on Linux isn’t as hard as it sounds.

In fact, there are multiple tools at your disposal, depending on the distribution you use. However, remember that non-root users can’t grant admin rights to anyone, so you’ll need to sign in as another user that does have the admin status.

These users, technically defined, belong to the sudo or sudoers group. This means that they can issue sudo commands by entering their user passwords. Passwords are required to authorize users so that they can execute administrative tasks on the system.

Related: How to Manage User Groups With Groupadd on Linux

To gain admin rights, you need to belong to the right group, and we’ll explain how to do that below.

How to Grant Admin Permissions in Ubuntu

Desktop environments make it easy to control user permissions, regardless of your comfort level with the inner workings of Linux. You can use a GUI app to manage users on the desktop, or you can complete the same task with more efficiency through the command line.

Granting Admin Rights via the Desktop

In Debian-based distributions such as Ubuntu and Linux Mint, you’ll find a user management tool in your system settings. Search for user in the app launcher and the user management utility will usually be on top of the results.

After launching the tool, look for an option to modify a user’s rights, groups, or advanced controls. If you can edit a user’s groups, make sure to add the user in the sudo or sudoers group.

Granting Admin Rights via Command Line

Two different commands can grant admin rights in Ubuntu: usermod and gpasswd.

To grant administrative rights using usermod, open a terminal and enter:

sudo usermod -aG sudo username

Replace username with the username of your choice. The -aG flag stands for Append and Group. This command instructs usermod to append the username to a group, which in this case is the sudo group.

To use gpasswd, enter the following command in the terminal:

sudo gpasswd -a username sudo

Be sure to replace username with the username of the user you want to grant admin privileges to. The -a flag indicates that you want to Add the user to the sudo group.

Related: How to Add a User in Linux

How to Grant Admin Permissions in Arch Linux

Some Arch-based distros, like Manjaro Linux, have desktop-based user management apps similar to Ubuntu. However, if you can’t find one on your system, getting admin rights on Arch Linux via the command line is pretty straightforward as well.

You’ll need to edit the etc/sudoers file. Although tampering with system files can result in a broken system, a special command called visudo allows you to edit the file with minimal risk.

sudo visudo

Add the below line to the file, or uncomment it (by removing the hashmark) if the line’s already present. The line gives root access to the wheel group.

%wheel      ALL=(ALL) ALL

After saving and exiting from visudo, issue the following command to add the user to the wheel group, replacing username with the user of your choice.

sudo gpasswd -a username wheel

Creating New Admins in Linux

You’ve now added a user to your Linux admin group, and that user can perform administrative tasks like installing and updating software. Having multiple administrators can be beneficial if you’re running a large Linux server with multiple users.

If you’re often managing users on your Linux system, it’s key that you know how to quickly identify users. Listing all users that are present on a system is a great way to start.

Source: makeuseof.com

Related posts

Best Tablets for Kids in 2024

What Is a Snapchat Public Profile and How Do You Create One?

Connections #343: Today’s Answer and Clues (Sunday, May 19, 2024)