[root@hf-01 ~]# useradd user2
[root@hf-01 ~]# tail -n2 /etc/passwd
haha:x:1003:1003::/home/haha:/bin/bash
user2:x:1004:1004::/home/user2:/bin/bash
[root@hf-01 ~]# tail -n3 /etc/group
grp2:x:1005:
haha:x:1003:
user2:x:1004:
[root@hf-01 ~]# useradd -u 1005 -g grp2 user3
[root@hf-01 ~]# tail -n3 /etc/passwd
haha:x:1003:1003::/home/haha:/bin/bash
user2:x:1004:1004::/home/user2:/bin/bash
user3:x:1005:1005::/home/user3:/bin/bash
[root@hf-01 ~]# useradd -u 1008 -g grp2 -d /home/hanfeng -s /sbin/nologin user10
[root@hf-01 ~]# tail -n2 /etc/passwd
user4:x:1006:1005::/home/haha/:/sbin/nologin
user10:x:1008:1005::/home/hanfeng:/sbin/nologin
[root@hf-01 ~]# useradd -M user11
[root@hf-01 ~]# tail -n3 /etc/passwd
user8:x:1007:1005::/home/haha:/sbin/nologin
user10:x:1008:1005::/home/hanfeng:/sbin/nologin
user11:x:1009:1009::/home/user11:/bin/bash
[root@hf-01 ~]# !ls
ls /home/
haha hanfeng mysql user1 user2 user3 会看到用户的家目录下不存在user11
[root@hf-01 ~]# useradd user12
[root@hf-01 ~]# userdel user12
[root@hf-01 ~]# tail -n3 /etc/passwd
user4:x:1006:1005::/home/haha/:/sbin/nologin
user8:x:1007:1005::/home/haha:/sbin/nologin
user10:x:1008:1005::/home/hanfeng:/sbin/nologin
[root@hf-01 ~]# ls /home/
haha hanfeng mysql user1 user12 user2 user3
[root@hf-01 ~]# rm -rf /home/user12
[root@hf-01 ~]# userdel -r user3
[root@hf-01 ~]# ls /home/
haha hanfeng mysql user1 user2