linux用户管理相关命令

查看用户以及用户组:
cat /etc/group
 
[root@izuf60kjjii4iwkhdsly3bz html]# cat /etc/group
 
内容具体分析
/etc/group 的内容包括用户组(Group)、用户组口令、GID及该用户组所包含的用户(User),每个用户组一条记录;格式如下:
group_name:passwd:GID:user_list
在/etc/group 中的每条记录分四个字段:
第一字段:用户组名称;
第二字段:用户组密码;
第三字段:GID
第四字段:用户列表,每个用户之间用,号分割;本字段可以为空;如果字段为空表示用户组为GID的用户名
 
 
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:
cdrom:x:11:
mail:x:12:postfix
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:30:
video:x:39:
ftp:x:50:
lock:x:54:
audio:x:63:
nobody:x:99:
users:x:100:
utmp:x:22:
utempter:x:35:
ssh_keys:x:999:
input:x:998:
systemd-journal:x:190:
systemd-network:x:192:
dbus:x:81:
polkitd:x:997:
postdrop:x:90:
postfix:x:89:
chrony:x:996:
sshd:x:74:
ntp:x:38:
tcpdump:x:72:
nscd:x:28:
screen:x:84:
mysql:x:1000:
www:x:1001:
saslauth:x:76:
dingheng:x:1002:
phpers:x:1003:
ykd:x:1008:
apache:x:48:
 
 
/etc/shadow和/etc/passwd系统存在的所有用户名
 
将用户添加到某一个用户组:
 
usermod -G groupA
 
 
这样做会使你离开其他用户组,仅仅做为用户组 groupA 的成员。
应该加上 -a 选项:
usermod -a -G groupA user
 
 
(FC4: usermod -G groupA,groupB,groupC user)
-a 代表 append, 也就是将自己添加到用户组 groupA, 而不必离开原来到用户组。
 
 
命令的所有的选项,及其含义:
Options:
-g, --gid GROUP               force use GROUP as new primary group
-G, --groups GROUPS           new list of supplementary GROUPS
-a, --append          append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                him/her from other groups
 
 
-c, --comment COMMENT         new value of the GECOS field
-d, --home HOME_DIR           new home directory for the user account
-e, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
-f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
-h, --help                    display this help message and exit
-l, --login NEW_LOGIN         new value of the login name
-L, --lock                    lock the user account
-m, --move-home               move contents of the home directory to the new
                                location (use only with -d)
-o, --non-unique              allow using duplicate (non-unique) UID
-p, --password PASSWORD       use encrypted password for the new password
-s, --shell SHELL             new login shell for the user account
-u, --uid UID                 new UID for the user account
-U, --unlock                  unlock the user account
 

查看用户所属用户组

查看用户所属的组使用命令:groups user
或者查看文件:cat /etc/group 
posted @ 2020-02-27 20:49  yokooo  阅读(279)  评论(0编辑  收藏  举报