Linux下的用户管理(User management under Linux)-LINUX
Linux下的用户管理(User management under Linux)
一、添加用户
useradd UserName
useradd -g GroupName UserName //创建并添加至组
示例
useradd tom
说明:
- 1.当创建用户成功后,会自动的创建和用户名相同的home目录
- 2.也可以通过 useradd -d 目录名指定目录
二、指定/修改密码
passwd 用户名
三、删除用户
userdel UserName
- 删除用户 userdel UserName
- 删除用户以及home目录 userdel -r UserName
四、查找用户
显示:
id userName
uid=0(root) gid=0(root) groups=0(root)
五、切换用户
su - 用户名
注意:
- 从权限高的用户切换至权限低的用户,不需要输入密码,反之需要
- 当需要返回到原来的用户时,使用“exit/logout指令
六、查看当前用户/登录用户
whoami
[用户组]
- 创建组 groupadd GroupName
- 删除组 groupdel GroupName
- 添加用户并添加至组 useradd -g GroupName UserName
- 修改用户组 usermod -g GroupName UserName
用户/组相关文件
- /etc/passwd文件
用户的配置文件,记录用户的各种信息
每行含义:用户名:口令:用户标识号:组标识号:注释性描述:主目录:登录shell - 用户的配置文件,记录用户的各种信息
- 每行含义:用户名:口令:用户标识号:组标识号:注释性描述:主目录:登录shell
- /etc/shadow文件
口令的配置文件
每行含义:登录名:加密口令:最后一次修改时间:最小时间间隔:最大时间间隔:警告时间:不活动时间:失效时间:标志 - 口令的配置文件
- 每行含义:登录名:加密口令:最后一次修改时间:最小时间间隔:最大时间间隔:警告时间:不活动时间:失效时间:标志
- /etc/group文件
组的配置文件,记录Linux包含的组信息
每行含义:组名:口令:组标识符号:组内用户列表 - 组的配置文件,记录Linux包含的组信息
- 每行含义:组名:口令:组标识符号:组内用户列表
————————
< strong > I. add user < / strong >
useradd UserName
useradd -g GroupName UserName //创建并添加至组
Examples
useradd tom
explain:
- 1. When the user is created successfully, the home directory with the same user name will be automatically created
- 2. You can also specify the directory by useradd – D directory name
< strong > II. Specify / modify password < / strong >
passwd 用户名
< strong > III. delete user < / strong >
userdel UserName
- 删除用户 userdel UserName
- 删除用户以及home目录 userdel -r UserName
< strong > IV. find users < / strong >
Display:
id userName
uid=0(root) gid=0(root) groups=0(root)
< strong > v. switching users < / strong >
su - 用户名
be careful:
- When you switch from a user with high permission to a user with low permission, you do not need to enter a password, but vice versa
- When you need to return to the original user, use the ` ` exit / logout command
< strong > VI. view the current user / login user < / strong >
whoami
< strong > [user group] < / strong >
- 创建组 groupadd GroupName
- 删除组 groupdel GroupName
- 添加用户并添加至组 useradd -g GroupName UserName
- 修改用户组 usermod -g GroupName UserName
< strong > user / group related files < / strong >
- /Etc / passwd file
The user’s profile records various information of the user
Meaning of each line: user name: Password: user ID number: group ID number: annotative Description: Home Directory: login shell - The user’s profile records various information of the user
- Meaning of each line: user name: Password: user ID number: group ID number: annotative Description: Home Directory: login shell
- /Etc / shadow file
Password profile
Meaning of each line: Login Name: encryption password: last modification time: minimum time interval: maximum time interval: warning time: inactive time: expiration time: Flag - Password profile
- Meaning of each line: Login Name: encryption password: last modification time: minimum time interval: maximum time interval: warning time: inactive time: expiration time: Flag
- /Etc / group file
Group configuration file, which records the group information contained in Linux
Meaning of each line: Group Name: Password: group identifier: list of users in the group - Group configuration file, which records the group information contained in Linux
- Meaning of each line: Group Name: Password: group identifier: list of users in the group