I am adding a user named 'test' in my Ubuntu 18.04 server. When I add the user using adduser
, like this:
sudo adduser --system --group test --shell /bin/bash
all goes well, I can login fine, but .bashrc, .bash_logout and .bash_profile are not made by default in the home dir. Whereas when I added the user using useradd
like this:
sudo useradd -m test -s /bin/bash
the user is added in the same way as adduser
and I have a preconfigured .bash_profile, .bashrc and .bash_logout in the home dir.
Can someone explain why is there a difference ? Am I missing any flag in adduser
usage ?
This behavior of
adduser
is due to the option--system
. With this option you are create a system user, with UID under 1000. Fromman adduser
:The skeletal configuration files are these files, located in
/etc/skel
, that are copied do the user's home directory when a new normal user is added to the system.If you want to add a normal user, by default, you do need to add any options to
adduser
, just use:On the other hand, if you want to create fully qualified normal user by
adduser
you need to add few additional options, for example-m
to create user's home directory and copy the content of/etc/skel
.Read also: At what point is the ~/.bashrc file created?