Creating A User with Different Home Directory in Linux

5

Linux is an impressive multi-user running device. It will have many concurrent customers gaining access to the device on the identical time. The device admin can arrange permissions for every consumer to specify which consumer can get right of entry to what a part of the device.

This information will display methods to create a brand new consumer with a distinct house listing in Linux.

User house listing

In Linux, every consumer will get its own residence listing with exceptions like more than a few device accounts. The house listing is a devoted listing for the specific consumer to retailer the user-specific information. It’s additionally known as the “login directory”. Whenever logging in, the consumer will land at the respective house listing.

By default, the entire customers within the device have their house directories situated on the following location.


Each house listing is known as after the username of the consumer. For instance, the house listing for the consumer “viktor” will appear to be this.


However, we will be able to determine a distinct location for the consumer listing. It can also be set all the way through the introduction of the consumer account or moved later.

Creating a consumer with a distinct house listing

Creating a brand new consumer

Each Linux device comes with useradd, a devoted instrument to create and replace consumer accounts. It’s handiest to be had to the basis consumer and non-root customers with sudo privileges.

To upload a brand new consumer to the device, run the next useradd command. The flag “-m” tells useradd to create a devoted house listing for the brand new consumer. If now not used, then the consumer received’t have a devoted house listing.

$ sudo useradd -m username>


The consumer is added to the device. The consumer could also be registered to more than a few database information (/and so forth/passwd, /and so forth/shadow, /and so forth/gshadow, and /and so forth/crew).

The consumer isn’t obtainable but. The following command will assign a login password for the brand new consumer.


The consumer is in a position and entirely useful. Access the brand new consumer.

Check the site of the house listing of the brand new consumer.

Creating a consumer with a customized house listing

By default, useradd will create the consumer’s house listing underneath “/home”. To specify the house listing in a distinct location, use the flag “-d”. Note that the listing will have to exist previously.

$ sudo useradd -m -d custom_home_dir_location> username>


As all the time, use passwd to assign a login password for the brand new consumer.


Verify if the brand new consumer has a distinct house listing.

Moving current consumer house listing

We too can assign a distinct house listing for an current consumer. It is not going to transfer the contents of the present house listing robotically to the brand new location.

Create a brand new listing. It would be the new house listing of an current consumer.

$ mkdir -pv /further/new_home


Allow the brand new consumer whole get right of entry to over the brand new listing.

$ sudo chown username> /further/new_home


Move the entire contents of the present consumer house listing to the brand new one.

$ sudo mv /house/username>/* /further/new_home

Assign the brand new listing as the house of the consumer.

$ sudo usermod -d /further/new_home -m username>


Verify the trade.

Final ideas

The house listing is a very powerful a part of a regular consumer account on Linux. This information demonstrates methods to assign a customized house listing to a brand new and current consumer. These strategies practice to any Linux distro.

Happy computing!

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More