-c, --comment COMMENT GECOS field of the new account 说明 -d, --home-dir HOME_DIR home directory of the new account 家目录 -g, --gid GROUP name or ID of the primary group of the new account 初始组id或组名,默认是与用户名相同 -G, --groups GROUPS list of supplementary groups of the new account 附加组 -p, --password PASSWORD encrypted password of the new account 密码 -r, --system create a system account 创建一个系统用户 -s, --shell SHELL login shell of the new account 登录shell,默认是bin/bash -u, --uid UID user ID of the new account 用户id
修改用户信息
1 2 3 4 5 6 7 8 9 10 11 12
usermod [options] 用户名
-c, --comment COMMENT GECOS field of the new account 说明 -d, --home-dir HOME_DIR home directory of the new account 家目录 -g, --gid GROUP name or ID of the primary group of the new account 初始组id或组名,默认是与用户名相同 -G, --groups GROUPS list of supplementary groups of the new account 附加组 -p, --password PASSWORD encrypted password of the new account 密码 -r, --system create a system account 创建一个系统用户 -s, --shell SHELL login shell of the new account 登录shell,默认是bin/bash -u, --uid UID user ID of the new account 用户id
删除用户
1 2 3
userdel [-r] 用户名
-r 表示删除用户的同时删除家目录
切换用户
1
su - 用户名
密码设置修改
1 2 3 4 5
#密码设置 passwd 用户名
#对于普通用户来说,只可以修改当前用户密码,不需要指定用户名 passwd
组命令
添加组
1
groupadd 组名
删除组
1
groupdel 组名
把用户加入组或者删除组
1 2 3 4 5
gpasswd [options] 组名
-a, --add USER add USER to GROUP 把用户加入组 -d, --delete USER remove USER from GROUP 把用户移出组