New answers tagged useradd
The -M flag for useradd means "do not create the user's home directory", so the program has done what you asked. You can fix the problem by creating a home directory for Alice and copying in the template files: home=$(getent passwd Alice | cut -d: -f6) uid=$(getent passwd Alice | cut -d: -f3) gid=$(getent passwd Alice | cut -d: -f4) mkdir -m755 "$home" cp ...
Logging in with home= "/" means what it says. Since there is no home directory for the user, the login has used the root directory "/" The -bash-4.1$ is the default bash prompt. You see that when there is no ~/.bashrc nor other default bash files. These are normally created, stored and updated in the user's home directory. Using "/" as the home ...
I think you can solve it like that: mkdir /home/Alice chown -R Alice:Alice /home/Alice Even better if you use adduser instead of useradd, the directory will create automatically.
According to useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel GROUPS=video,dialout CREATE_MAIL_SPOOL=no SKEL= [path] is your skeleton directory.
As thrig pointed out, all that's needed is to create the directory structure that you want under /etc/skel. Quoting from the useradd man page -k, --skel SKEL_DIR The skeleton directory, which contains files and directories to be copied in the user's home directory, when the home directory is created by useradd. This option is only valid if the -m ...
Because $ is a special character to the shell you should put the password in between single quotes: useradd -p '$6$Ic2PVlwi$2nf.IRWTMy0FHrPza6mh5wjomwbYtIIxnzxPZL7yg8SsvOdbjEpoI0G8uy7AqduYKQOn2R/rnnaalRmfPMy.a0' bwong20 without these the shell will try to expand $6, $Ic2PVlwi and $2 to their respective variable values, and as the variables are not set, ...
You can to do it using passwd's -e option after creating the account. useradd has -e option for expiring a user account, not password. From man passwd: -e, --expire Immediately expire an account's password. This in effect can force a user to change his/her password at the user's next login.
Top 50 recent answers are included