Ubuntu (Linux) Add new users and grant permissions, delete users

This article takes creating a user with the usernamezml as an example.

1. Add users

1.1 Add users and create user directories

sudo useradd -m -s /bin/bash zml

-m: Automatically create the user's login directory
-s: Specify the user's identity after login as the shell group

1.2 Create (change) user secrets

sudo passwd zml

Insert image description here

1.3 Add permissions

chmod +w /etc/sudoers  # 给文件增加w权限
vim /etc/sudoers   # 修改文件
zml ALL=(ALL:ALL) ALL  # 在root ALL=(ALL:ALL) ALL后增加
chmod -w /etc/sudoers  # 去除文件w权限

2. Delete users

2.1 Delete user

sudo userdel zml

2.2 Delete user directory

sudo rm -rf /home/zml

2.3 Delete user-related configurations

Delete or comment out the configuration of the user to be deleted in /etc/sudoers, otherwise the user with the same name cannot be created again.

Guess you like

Origin blog.csdn.net/sdbyp/article/details/123936216