How do I add a user in Linux without a home directory?

9

While managing users, Linux administrators need to manage different types of users based on the privileges he/she wants to set. User management includes access control and Group management of the user. It is often seen that when we create users in Linux, there are two types of commands available useradd and adduser. We will add a user in Linux without a home directory using the useradd command in this post.

useradd Command

The useradd is a command used for creating a user in any Linux-based operating system. It is a low-level or less secure command for creating a user because it only creates a user until we specify a flag.

This command does not automatically create a home directory until a -m flag is specified.

Without a Home Directory flag

Moreover, this command also provides a flag or option if you do not want to create a home directory of a user while creating a user.

-M for creating a user without a Home directory
–no-create-home is also used for not creating a home directory of a user

For example,

OR

$ useradd –no-create-home username>

Let’s do some practical, create users using the useradd command and witness it.

Create a user using the useradd Command

To create a user using the useradd command, type the command given below:

In the above command, Ivan is the username, so provide your username at the place of Ivan.

You can witness in the screenshot attached; the user is created without asking for any password.

To create a password for this user, execute the command given below:

Type the new password you want to set for the user:

how do i add a user in linux without a home directory? How do I add a user in Linux without a home directory? 1624069720 279 How do I add a user in Linux without a

After successfully creating a user and setting its password, log in to the user profile using the command given below:

how do i add a user in linux without a home directory? How do I add a user in Linux without a home directory? 1624069720 150 How do I add a user in Linux without a

Type the recently created password for the newly created user:

how do i add a user in linux without a home directory? How do I add a user in Linux without a home directory? 1624069721 726 How do I add a user in Linux without a

You can see we are logged in to Ivan’s shell, and you can also witness that the user does not have the home directory.

Wrap Up

User management is an extremely responsible task for any Linux administrator. Due to the security reasons and privileges of the users, Linux administrators have to create some users without a home directory. This article provides to-the-point detail for creating a user without a home directory.

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