Sudo privileges allow regular users to run commands that require administrative privileges. All user that belong to user group sudo have sudo privileges. But sometimes you may need to remove sudo privileges of users in Linux. In this article, we will look at how to remove sudo privileges in Linux.
How to Remove Sudo Privileges in Linux
Here are the steps to add sudo privileges to regular user in Linux. For example, let us create new user test_user with the following command.
$ sudo useradd test_user
Here is the command to give sudo privileges to newly added user.
$ sudo usermod -a -G sudo test_user
If you want to give sudo privileges to new user at the time of creation, just add sudo keyword at the end of useradd command.
$ sudo useradd test_user sudo
You may need to logout and login again to apply changes.
To remove sudo privileges for a user, use deluser command as shown below. It will only take the sudo permission away and will not delete the user. Make sure to add sudo keyword at the end of useradd command.
$ sudo deluser test_user sudo
You will see the following output.
Removing user `test_user' from group `sudo' ... Done.
You may alternatively use the gpasswd command to remove sudo privileges for a user.
$ sudo gpasswd -d test_user sudo
Please be careful when you remove sudo privileges for a user. If there is only one user with sudo privileges on your system, then you will not be able to perform any administrative tasks such as installation, updating or removing programs.