One, user group
1. Create a user group
- Command format
groupadd 组名
- Example
groupadd testgroup # 添加用户组 testgroup
cat /etc/group | grep testgroup #查看用户组
2. Delete user group
- Command format
groupdel 组名
- Example
groupdel testgroup # 删除用户组
3. View user groups
- Command
cat /etc/group
view all to
cat /etc/group | grep 组名
see if a single exists - Example
cat /etc/group
root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:syslog
tty:x:5:
disk:x:6:
lp:x:7:
mail:x:8:
news:x:9:
uucp:x:10:
---- 省略 部分----
Second, the user
1. Add users
- command
useradd -m -g 组 新建用户名
-m automatically creates a user's home directory;
-g specifies the user's group
- Example
useradd -m -g testgroup zhangsan # 创建用户 zhangsan 指定用户组testgroup
2. Delete user
- command
userdel [options] 用名
options description:
-f force deletion, file
-r removes the user's home directory
- Example
userdel -r zhangsan # 删除用户 zhangsan 同时移除主目录
3. Modify or add password
- command
passwd 用户名
- Example
passwd zhangsan # 为用户 zhangsan 新增或修改密码
Three, the problem
1、/usr/bin/xauth: file /home/user/.Xauthority does not exist
The reason for the error:
because the corresponding directory was not authorized when adding a user, only useradd user was executed without authorization of the corresponding user directory
Solution
Execute the following command:
chown username:usergroup -R /home/user_dir
Simultaneous execution
usermod -s /bin/bash username
(specify shell, otherwise it will be very inconvenient for terminal operation)