2.创建用户new备注用户为test,指定用户UID为600,用户的组初始组为test、用户的次要组为mysql,指定用户的失效日期(注意这里的失效日期也是需要通过1970年1月1日进行换算)、指定用户的过期天数

3.创建系统用户old
创建的系统用户虽然在用户文件中有指定家目录,但是实际上在home目录下并不会创建对应用户的目录,且不会创建用户邮件通知目录。

4.创建不允许登入的用户

5.指定用户家目录
先创建用户家目录
[root@localhost ~]# mkdir -p /test/home [root@localhost ~]# mkdir /test/home/testuser
创建用户并指定家目录
[root@localhost ~]# useradd -d /test/home/testuser testuser useradd: warning: the home directory already exists. Not copying any file from skel directory into it.
注意:这里的家目录是绝对路径,也就是你指定了那个目录家目录就是哪个目录不会在你指定的目录下再创建目录,这里会有警告说用户不能拷贝文件到家目录,因为家目录的权限还是之前创建目录用户的权限,这个时候需要给家目录赋予用户拥有者。
[root@localhost ~]# chown testuser:testuser /test/home/testuser [root@localhost ~]# ll /test/home total 4 drwxr-xr-x. 2 testuser testuser 4096 May 5 06:22 testuser [root@localhost ~]#
删除用户
userdel [options] LOGIN
-f, --force 强制删除用户,不管该用户是否在使用








