首先请注意,最好使用adduser而不是useradd。
现在回到您的命令:
您应该以以下方式运行命令:
sudo useradd -m -c "Samwise the Brave" sam -s /bin/bash
man useradd
-s, --shell SHELL
The name of the user's login shell. The default is to leave this
field blank, which causes the system to select the default login
shell specified by the SHELL variable in /etc/default/useradd, or
an empty string by default.
-m, --create-home
Create the user's home directory if it does not exist. The files
and directories contained in the skeleton directory (which can be
defined with the -k option) will be copied to the home directory.
By default, if this option is not specified and CREATE_HOME is not
enabled, no home directories are created.
因此,您错过了用于-s
添加登录Shell和-m
创建家庭的信息。
如果要同时添加多个用户,最好使用命令newusers
。它将简化您的任务。
man newusers
DESCRIPTION
The newusers command reads a file of user name and clear-text password
pairs and uses this information to update a group of existing users or
to create new users. Each line is in the same format as the standard
password file (see passwd(5)) with the exceptions explained below:
pw_name:pw_passwd:pw_uid:pw_gid:pw_gecos:pw_dir:pw_shell
这里有一些关于newusers
命令的教程: