Ubuntu article thumbnail image.

How do you remove a user's sudo privileges on a Ubuntu operating system?

To do this, you need to remove your user from the sudo group on the machine.

You can do this with this command (replace bob with your user's name):

deluser bob sudo

This will only take sudo access away from the user profile and will not delete the user itself.

Let's test whether or not the user has been removed from the sudo group.

First, switch over and use your user that sudo access was revoked from:

su - bob

Then, run this command to list out the contents of the /root directory. This directory is normally only accessible to the root user.

sudo ls -la /root

This command should fail and output something similar:

bob is not in the sudoers file. This incident will be reported.

If your output matches the above or the command fails, you have successfully removed your user's sudo privileges.

Thanks for reading and happy coding!

About the author

Hi, I'm Nick Major. I'm a software developer from Wisconsin, United States.

I create free and premium courses, have published hundreds of informational coding articles, and am currently a Frontend Software Engineer at RoundingWell.

You can read more about me here.

Picture of Nick Major.