ubuntu switch administrator account (ubuntu delete user command)

PHPz
Release: 2024-02-13 14:51:22
forward
1272 people have browsed it

ubuntu switch administrator account (ubuntu delete user command)

php editor Zimo will introduce you to the method of switching administrator accounts in Ubuntu system, as well as the command to delete users. In the Ubuntu system, the administrator account has higher permissions and can perform system-level operations. When you need to perform some system-level tasks, it is very necessary to switch to the administrator account. At the same time, deleting users is also one of the common management operations and can be easily completed through specific commands. The specific steps will be introduced in detail below to help you better manage your Ubuntu system.

— Sk

As you know, users can perform any administrative tasks using sudo privileges on Ubuntu systems. When you create new users on a Linux machine, they cannot perform any administrative tasks until you make them a member of the sudo group. In this short tutorial, we'll show you how to add a normal user to the sudo group and remove permissions so that they become a normal user.

Granting sudo permissions to normal users on Linux

Normally, we use the adduser command to create a new user as shown below.

$ sudo adduser ostechnix

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

$ sudo usermod -a -G sudo hduser

The above command will make 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 the new user for this change to take effect. At this point the user has become an administrative user.

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

$ sudo mkdir /test

[sudo] password for ostechnix:

Remove user's sudo permissions

Sometimes, You may want to remove sudo privileges from a specific user without removing it in Linux. To make any user a normal user, just remove them from the sudo group.

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

$ sudo deluser ostechnix sudo

Example output :

Removing user `ostechnix' from group `sudo' …

Done.

This command only removes user ostechnix from the sudo group, but The user is not permanently removed from the system. Now, it becomes a normal user and cannot perform any administrative tasks like a sudo user.

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

$ sudo gpasswd -d ostechnix sudo

Remove from the sudo group Please use caution. Do not remove real administrators from the sudo group.

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

$ sudo -l -U ostechnix

User ostechnix is ​​not allowed to run sudo on ubuntuserver.

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

Please 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, then you will not be able to perform any administrative operations such as installing, removing, and updating programs on the system. So, please be careful. In our next tutorial, we will explain how to restore a user's sudo permissions.

That’s it. Hope this article is useful. There are more goodies. Stay tuned!

The above is the detailed content of ubuntu switch administrator account (ubuntu delete user command). For more information, please follow other related articles on the PHP Chinese website!

source:jingfakeji.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template