Question

Linux adduser command needs --home Dir option

New account with “adduser user”

After ssh into root@ipAddress, I tried to create a new user account as “Initial Server Setup with Ubuntu 14.04” suggested. The new account was created, but with some anomalies:

  1. No “user@hostname” in the shell prompt
  2. No /home/user directory
  3. No /bin/bash shown in /etc/passwd
  4. Unable to “deluser user”

For example,

after “adduser leon” and login as leon: $ id uid=1000(leon) gid=1000(leon) groups=1000(leon),27(sudo) $ grep -i leon /etc/passwd leon:x:1000:1000::/home/leon: $ su root root@Leon-Ubuntu:/# deluser leon Removing user leon' ... Warning: group leon’ has no more members. userdel: user leon is currently used by process 2060 /usr/sbin/deluser: `/usr/sbin/userdel leon’ returned error code 8. Exiting.

Then I tried the “–home Dir” option

and it works well.

root@Leon-Ubuntu:/# adduser --home /home/leon2 leon2 root@Leon-Ubuntu:/# grep -i leon /etc/passwd leon:x:1000:1000::/home/leon: leon2:x:1001:1001:,:/home/leon2:/bin/bash root@Leon-Ubuntu:/# ls /home/ leon2 root@Leon-Ubuntu:/# deluser leon2 Removing user leon2' ... Warning: group leon2’ has no more members. Done.

Is there an explanation about this?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This is odd and I cannot say that I have encountered this on Ubuntu 16.04 myself but I was able to find some information indicating that others have experienced this issue with the default adduser command in Ubuntu 16.04. It seems the issue lies with the command reading and using the defaults specified for it.

You can find some suggestions and more information here.