How To Grant And Remove Sudo Privileges To Users On Ubuntu

As you know already, the user can perform any administrative tasks with sudo privileges on Ubuntu systems. When creating a new users on your Linux box, they can’t do any administrative tasks until you make them to be a member of ‘sudo’ group. In this brief tutorial, we explain how to add a regular user to sudo group and remove the given privileges to make it as just a normal user.
Grant Sudo Privileges To A regular User On Linux
Usually, we use ‘adduser’ command to create new user like below.
$ sudo adduser ostechnix
If you want the newly created user to perform any administrative tasks with sudo, just add him to the sudo group using command:
$ sudo usermod -a -G sudo ostechnix
The above command will make the user called ‘ostechnix’ to be the member of sudo group.
You can also use this command too to add the users to sudo group.
$ sudo adduser ostechnix sudo
Now, log out and log in back as the new user for this change to take effect. The user has now become an administrative user.
To verify it, just use ‘sudo’ as prefix in a any command.
$ sudo mkdir /test [sudo] password for ostechnix:
Remove sudo privileges of an User
Sometimes, you might want to remove sudo privileges to a particular user without deleting it from your Linux box. To make any user as a normal user, just remove them from the sudo group.
Say for example If you want to remove a user called ostechnix, from the sudo group, just run:
$ sudo deluser ostechnix sudo
Sample output:
Removing user `ostechnix' from group `sudo' ... Done.
This command will only remove user ‘ostechnix’ from the sudo group, but it will not delete the user permanently from the system. Now, He becomes a regular user and can’t do any administrative tasks as sudo user.
Also, you can use the following command to revoke the sudo access from an user:
$ sudo gpasswd -d ostechnix sudo
Please be careful while removing users from the sudo group. Do not remove the real administrator from the “sudo” group.
Verify the user “ostechnix” has been really removed from sudo group using command:
$ sudo -l -U ostechnix User ostechnix is not allowed to run sudo on ubuntuserver.
Yes, the user “ostechnix” has been removed from sudo group, and he can’t execute any administrative tasks.
Please be careful while removing a user from a sudo group. If you have only one sudo user on your system and you remove him from the sudo group, you can’t perform any administrative stuffs such as installing, removing and updating programs on your system. So, please be careful. In our next, tutorial, we will explain how to restore sudo privileges to a user
Suggested read:
- How To Find All Sudo Users In Your Linux System
- How To Restore Sudo Privileges To A User
- How To Run Particular Commands Without Sudo Password In Linux
And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned!
::...免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:
或是邮件反馈可也:
askdama[AT]googlegroups.com
订阅 substack 体验古早写作:
点击注册~> 获得 100$ 体验券:
关注公众号, 持续获得相关各种嗯哼:
自怼圈/年度番新

关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::