Back to blog
GuidesSeptember 5, 2026·5 min read

How to Create a User in Linux (With Home Directory)

How to Create a User in Linux (With Home Directory)

The quickest way: useradd -m

Most efficient way would be the usage of the useradd command with the -m option.

Invoke sudo useradd -m username in order to add new user and his home directory in one go. The flag -m tells useradd to create a home directory in default place /home/username and copy all standard files from /etc/skel into it.

For example:

sudo useradd -m alice

Here we've created the account, created /home/alice and copied all files from /etc/skel into it as the basic set of files for the new user.

Verification of the creation of a home directory

Check for the presence of the directory and ownership:

ls -la /home/alice
id alice
getent passwd alice

First command shows that there is such directory and gives its ownership and permission bits. The second id command shows that there is the account in question along with its UID and GID. Third command getent passwd shows the complete entry in the password file, including the actual path to the home directory of the user, which is especially useful if you've chosen to specify your own path to it and want to check whether it was configured correctly.

Setting password for a new user

The useradd command creates the account in the locked state, without a password configured. You can assign the password using the command:

sudo passwd alice

You'll be asked for the password and confirmation of it. Until this step will be done (or the alternate ssh key authentication will be configured) this account can not be used for logins.

The reason for a lack of a home directory while using useradd

Now let's clarify why in some cases the account created by simple invocation useradd alice doesn't have home directory.

From the useradd manual we know that option -m creates a home directory «if this option is not specified and CREATE_HOME is not enabled», meaning that there's some dependency on the value of CREATE_HOME parameter in /etc/login.defs. In Red Hat-like distributions this value is usually set to yes, resulting in home directory creation automatically, even without -m. In Debian/Ubuntu distributions, on the other hand, this value is not set, so if -m is not invoked the account will not have the home directory. If you want to make your setup script work with many different distributions, it's better to use useradd -m explicitly.

Alternative useradd: adduser

In Debian and Ubuntu distributions there's an alternative adduser command, which is not just friendly alias for the same function. The useradd is the low-level binary available in all Linux distributions, but in Debian distributions there's an additional adduser script, which uses useradd under the hood, prompts the user about password and other information and creates home directory by default without -m.

For example:

sudo adduser alice

But there's one important thing: adduser is not available everywhere. In Fedora/RHEL distributions, for example, adduser is just a symbolic link to useradd and works the same way, often without prompts. So if you want to create a setup script for many different distributions, it's better to use useradd -m, because the behavior is independent of the distribution.

Customizing the account

There're some options that will cover common customization of an account:

Option

Description

-m, --create-home

Creates the home directory if it does not already exist

-d, --home-dir DIR

Use the given home directory (rather than default /home/username)

-k, --skel DIR

Use the specified skeleton directory (rather than default /etc/skel)

-s, --shell SHELL

Use the given shell (for example, /bin/bash)

-G, --groups GROUP1,GROUP2

Add user to the additional groups

-c, --comment "Full Name"

Set the GECOS field (full name of the user)

For example:

sudo useradd -m -d /srv/users/alice -s /bin/bash -G sudo,docker -c "Alice Chen" alice

Here the account is created with custom home directory location outside the default /home hierarchy, /bin/bash is set as login shell, user is put into sudo and docker groups and his full name is specified in GECOS field.

Fixing the existing account without a home directory

If there's already an account created without -m and you found out that it is missing the home directory, there's no need to delete and recreate it. You can create it and direct the account to this directory:

sudo usermod -d /home/alice -m alice

With -m option in this case usermod will move contents of old home directory (if it existed) to the new directory; if there were no old home directory at all, then the new /home/alice will be created from scratch. After that you need to manually copy skeleton files and change ownership, as usermod does not do it like useradd -m:

sudo cp -rT /etc/skel /home/alice
sudo chown -R alice:alice /home/alice

These steps are typical for the initial server configuration. OrbitServers VPS and bare-metal instances typically come with full root access right after boot, allowing useradd -m to work as intended without any additional configuration.

Get started with Orbit Servers

Low-latency VPS, bare metal, and colocation across the US, EU, and APAC - provisioned instantly and built for performance-critical workloads.

Get started
J

Written by

Julius

Related posts