If you have multiple user accounts in your system, it is not a good idea to give administrative privileges to all of them. It is always safe to limit the privileges of certain accounts to prevent unauthorized and potentially harmful changes to the system.
However, if you want to assign administrative privileges to certain users, you can do it using various methods. In this article, we will discuss the methods you can use to make a user an administrator in your Debian operating system. This includes both the GUI and the command line. When you make a user an administrator, they are given all administrative privileges, such as installing and uninstalling software, making changes to system settings and configurations, etc.
We used Debian 11 and Debian 10 to successfully test the commands and procedures mentioned in this article.
Make a User an Administrator in Debian Through the GUI
In the following method, we will make a user an administrator though the Settings utility. To open the settings utility in your Debian system, hit the super key on your keyboard and type users. You will see the Settings icon in the results as shown in the following screenshot. Click on it to open the Settings utility directly in the Users tab.
Alternatively, go to the top right corner of your desktop and click on the downward arrow. From the menu that appears, click on the Account Settings to open the Settings utility in the Users tab.
When the settings utility will open, you will see the following view. To make the changes, make sure you have administrator privileges, otherwise, you will not be able to make any kind of changes.
Now you will need to unlock the tab to make required changes. To do so, click the unlock button at the top right corner of the following window.
You will be prompted to enter the password for the authorized user. Enter the password and click Authenticate.
Now you are allowed to make changes to any user’s settings. Select the user you want to make an administrator. There you will see two labels: Standard and Administrator next to the account type of the user. Click on the Administrator to assign the selected user an administrator privilege.
Make a User an Administrator in Debian Through the Command Line
In the following method, we will make the user an administrator through the following command line methods:
- Through the usermod command
- Through the gpasswd command
To open the command line terminal application in the Debian OS, go to the Activities tab in the top left corner of your desktop. Then in the search bar, type terminal. When the Terminal icon appears, click on to launch it.
Through the usermod command
To make a user an administrator, enter the command in the Terminal using the following syntax:
$ sudo usermod -aG sudo “username”
In the following example, we are going to make our user with the name “testuser” an administrator:
$ sudo usermod -aG sudo testuser
You will be prompted to enter the password. Enter the sudo password and the user will be added to the sudo group. The next time the user logs in, it will be granted sudo privileges.
To verify if the new user has been added to the sudo group, you can run the following command:
$ groups user_name
For instance, to verify if the “testuser” is in the sudo group, the command would be:
$ groups testuser
The output shows our user “testuser” is now in the sudo group and have all administrator privileges.
Through the gpasswd command
Another way of making a user an administrator is through the gpasswd command. To do so, open the Terminal and enter the command in the following syntax.
$ sudo gpasswd -a “user_name” sudo
For instance, to add “testuser” in the sudo group, the command would be:
$ sudo gpasswd -a testuser sudo
By running this command, our user will be added to the sudo group and will be granted administrator privileges.
In case, you want to remove the user from the sudo group added via gpasswd command, you can do so using the following command:
$ sudo gpasswd -a sampleuser sudo
For instance, to remove our user “testuser” from the sudo group, we will enter the following command:
$ sudo gpasswd -a testuser sudo
So these were some methods using which you can make an ordinary user an administrator so that they can perform any kind of administrative tasks on the system.