Feb 21, 2023 2 min read

Create Home Directory for Existing Users in Linux

Table of Contents

Looking for a way to create a home directory for the existing user? Well, here's a quick guide for you.

But before that, let's have a look at why there was no home directory for the user in the first place.

Reason why home directory was not created

So if you used the useradd command to add the new user in Linux, it won't add the home directory by default.

And if you insist on using the useradd command to create the new user, you just have to append the -m option and it will create a home directory by default.

Create the home directory for existing user

When the existing user does not have a home directory and tries login with the su - option, it will get you the following error:

su: warning: cannot change directory to home user: No such file or directory

Which clearly states that there is no home directory.

The first step is to log out from the user that does not have the home directory using the given command:

exit

Now, all you need to do is append the mkhomedir_helper and the username with the useradd command:

sudo mkhomedir_helper username

My user is named as Abhiman so my command would look like this:

sudo mkhomedir_helper Abhiman

And it will create a home directory for the user. For me, it will be named as /home/Abhiman:

ls -al /home/username
create home directory for existing user in linux

And if you are using desktop environments such as GNOME, KDE, etc. you will need to reboot your system to have sub-directories such as Downloads, Documents, and so on.

Bonus: Creating new users with the home directory

I prefer the adduser command for the reason that it allows the proper creation of a new user in Linux.

The regular useradd command is also capable of creating a new user with the home directory in this fashion:

sudo useradd -m new_user

Wrapping Up

This was a quick tutorial on how you can create a home directory for the existing user.

I won't recommend you to go with recreating the user (shown as a bonus tip) unless the user is recently made and you got to know that there is no home directory.

I hope you will find this helpful and if you have any queries, let me know in the comments.

Sagar Sharma
A software engineer who loves to tinker with hardware till it gets crashed. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.

Join the conversation

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Linux Handbook.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.