117

If you give a user sudo privileges how can I remove the sudo privileges and make the user become just a regular user?

I used:

sudo adduser username sudo

Now I've changed my mind.

guntbert
  • 13,134
Joe C
  • 1,335
  • 2
  • 10
  • 10
  • 1
    Take a read through this: http://askubuntu.com/questions/45035/disable-sudo-permission-to-user-from-command-line – Erresen Aug 22 '13 at 19:50

4 Answers4

134

Just type

sudo deluser username sudo

This will remove the user named username from the group sudo.

Be careful not to remove the real adminuser from the sudo group.

guntbert
  • 13,134
  • 3
    @abu-bua: Please don’t approve changes that add entirely different solutions to existing answers (a practice commonly called “piggy-back answer”). Those should be posted as separate answers instead. The appropriate rejection reason is: “This edit was intended to address the author of the post and makes no sense as an edit. It should have been written as a comment or an answer.” (emphasis mine) – David Foerster Oct 02 '18 at 18:16
  • deluser: command not found. in centos7. – Lei Yang Jan 31 '24 at 03:31
  • @LeiYang, apparently deluser is a debian thing - have a look at man groupmems . – guntbert Feb 01 '24 at 22:29
57

If you're like me, you are just trying to figure out how to take away sudo access from a user. It's easy, just open sudo, and type the following in. Keep in mind that USERNAME can be replaced by the profile you are doing this to. In terminal type:

sudo deluser USERNAME sudo

This will only take sudo access away from the profile named USERNAME, and will not delete!

David Foerster
  • 36,264
  • 56
  • 94
  • 147
Plane Guy
  • 620
14

You can also use gpasswd:

sudo gpasswd -d username sudo

This will remove username from group sudo.

Shayan
  • 441
0

In Ubuntu 22.04 cloud image none of the above worked. I had to also remove the default ubuntu user from file: /etc/sudoers.d/90-cloud-init-users

maiky
  • 158