[root@localhost ~]# groupadd test
[root@localhost ~]# tail -1 /etc/group
test:x:1001:
[root@localhost ~]# groupadd -g 501 test1
[root@localhost ~]# tail -2 /etc/group
test:x:1001:
test1:x:501:
[root@localhost ~]# groupdel test
[root@localhost ~]# groupdel test1
[root@localhost ~]# tail -5 /etc/group
postdrop:x:90:
postfix:x:89:
chrony:x:996:
ping:x:1000:
slocate:x:21:
[root@localhost ~]# groupdel ping
groupdel:不能移除用户“ping”的主组
[root@localhost ~]# useradd test
[root@localhost ~]# tail -1 /etc/passwd
test:x:1001:1001::/home/test:/bin/bash
[root@localhost ~]# useradd -u 1003 -g 1001 test1
[root@localhost ~]# tail -2 /etc/passwd
test:x:1001:1001::/home/test:/bin/bash
test1:x:1003:1001::/home/test1:/bin/bash
[root@localhost ~]# useradd -s /sbin/nologin -M test2
[root@localhost ~]# tail -3 /etc/passwd
test:x:1001:1001::/home/test:/bin/bash
test1:x:1003:1001::/home/test1:/bin/bash
test2:x:1004:1004::/home/test2:/sbin/nologin
[root@localhost ~]#
-s 制定 /sbin/nologin 表示不允许用户登陆
[root@localhost ~]# id
uid=0(root) gid=0(root) 组=0(root)
[root@localhost ~]# id 1001
uid=1001(test) gid=1001(test) 组=1001(test)
[root@localhost ~]# id test1
uid=1003(test1) gid=1001(test) 组=1001(test)
[root@localhost ~]# userdel test
userdel:没有删除 test 组,因为它是另外一个用户的主组。
[root@localhost ~]# tail -3 /etc/passwd
ping:x:1000:1000::/home/ping:/bin/bash
test1:x:1003:1001::/home/test1:/bin/bash
test2:x:1004:1004::/home/test2:/sbin/nologin
[root@localhost ~]# userdel -r test1
[root@localhost ~]# tail -3 /etc/passwd
chrony:x:998:996::/var/lib/chrony:/sbin/nologin
ping:x:1000:1000::/home/ping:/bin/bash
test2:x:1004:1004::/home/test2:/sbin/nologin
[root@localhost ~]# ls /home
ping test