.bashrc and .bash_profile not created with adduser but created with useradd

7,030

This behavior of adduser is due to the option --system. With this option you are create a system user, with UID under 1000. From man adduser:

If called with one non-option argument and the --system option, adduser will add a system user... A home directory is created by the same rules as for normal users. The new system user will have the shell /bin/false (unless overridden with the --shell option), and have logins disabled. Skeletal configuration files are not copied.

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:

sudo adduser username

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?

Share:
7,030

Related videos on Youtube

Adithya
Author by

Adithya

Updated on September 18, 2022

Comments

  • Adithya
    Adithya over 1 year

    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 ?

  • Adithya
    Adithya over 5 years
    Oh, my bad I didnt read the manual correctly. Got it, thx !