在root权限下,通过useradd命令可以为系统添加新用户信息,其中 options 为相关参数,user_name 为用户名称。
useradd [options] user_name
与用户账号信息有关的文件如下:
例如新建一个用户名为user_example的用户,在root权限下执行如下命令:
# useradd user_example
说明:
没有任何提示,表明用户建立成功。这时并没有设置用户的口令,请使用passwd命令修改用户的密码,没有设置密码的新账号不能登录系统。
使用id命令查看新建的用户信息,命令如下:
# id user_example
uid=502(user_example) gid=502(user_example) groups=502(user_example)
修改用户user_example的密码:
# passwd user_example
根据提示两次输入新用户的密码,完成密码更改。过程如下:
# passwd user_example
Changing password for user user_example.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
说明:
若打印信息中出现“BAD PASSWORD: The password fails the dictionary check - it is too simplistic/sytematic”,表示设置的密码过于简单,建议设置复杂度较高的密码。
上一篇