Editor's note: This answer is technically correct to the question as asked, but discussion in the comments clarified that the OP was trying to use
useradd in a script rather than directly as a shell command, and
adduser is less suited for that context.
When creating a user interactively, it's generally recommended to use
adduser rather than
useradd is a low level utility for adding users. On Debian,
administrators should usually use adduser(8) instead.
adduser is a friendlier frontend to
useradd and will do things like create user directories by default. When you run it with only a username as an argument, you will be prompted to provide additional information such as the password:
$ sudo adduser testuser
Adding user `testuser' ...
Adding new group `testuser' (1002) ...
Adding new user `testuser' (1002) with group `testuser' ...
Creating home directory `/home/testuser' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for testuser
Enter the new value, or press ENTER for the default
Full Name :
Room Number :
Work Phone :
Home Phone :
Is the information correct? [Y/n]
In general, it's recommended to use use
adduser instead of
useradd since this will also set up the required groups automatically. As explained in
adduser and addgroup add users and groups to the system according to
command line options and configuration information in
/etc/adduser.conf. They are friendlier front ends to the low level
tools like useradd, groupadd and usermod programs, by default choosing
Debian policy conformant UID and GID values, creating a home directory
with skeletal configuration, running a custom script, and other