Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to grant and remove sudo permissions on Ubuntu

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to grant and remove sudo permissions on Ubuntu". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Typically, we use the adduser command to create a new user, as shown below. Grant sudo permissions to ordinary users on Linux

$sudo adduser ostechnix

If you want the newly created user to perform administrative tasks using sudo, simply add it to the sudo group using the following command:

$sudo usermod-a-G sudo hduser

The above command makes the user named ostechnix a member of the sudo group.

You can also use this command to add users to the sudo group.

$sudo adduser ostechnix sudo

Now log out and log in as a new user for this change to take effect. At this point, the user has become an administrative user.

To verify it, simply use sudo as a prefix in any command.

$sudo mkdir / test [sudo] password for ostechnix:

Remove sudo permissions from a user

Sometimes, you may want to remove a specific user's sudo permissions without having to delete it in Linux. To make any user a normal user, simply remove it from the sudo group.

For example, if you want to remove a user named ostechnix from the sudo group, simply run:

$sudo deluser ostechnix sudo

Sample output:

Removing user `ostechnix' from group `sudo'... Done.

This command removes only the user ostechnix from the sudo group, but does not permanently remove the user from the system. Now it is a normal user, unable to perform any administrative tasks like a sudo user.

In addition, you can revoke a user's sudo access using the following command:

$sudo gpasswd-d ostechnix sudo

Be careful when removing users from the sudo group. Do not remove real administrators from the sudo group.

Use the command to verify that the user ostechnix has been removed from the sudo group:

$sudo-l-U ostechnixUser ostechnix is not allowed to run sudo on ubuntuserver.

Yes, user ostechnix has been removed from the sudo group and he cannot perform any administrative tasks.

Be careful when removing users from the sudo group. If you have only one sudo user on your system and you remove him from the sudo group, you will not be able to perform any administrative actions, such as installing, removing, and updating programs on the system.

That's all for "how to grant and remove sudo permissions on Ubuntu". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report