How to create a user without a home directory?

QuestionsQuestions8 SkillsProUser Account ManagementNov, 08 2025
0136

To create a user without a home directory in a Unix/Linux system, you can use the useradd command without the -m option. Here’s how to do it:

Command

Run the following command in your terminal:

sudo useradd username

Replace username with the desired username for the new user.

Explanation

  • sudo: Runs the command with superuser privileges.
  • useradd: The command used to create a new user.
  • username: The name of the user you want to create.

Example

For example, to create a user named alice without a home directory, you would run:

sudo useradd alice

Verification

To verify that the user has been created without a home directory, you can check the /etc/passwd file:

grep alice /etc/passwd

You should see an entry for alice that does not include a home directory path.

Important Note

Creating a user without a home directory is typically used for system accounts or users that do not require personal storage. If the user later needs a home directory, you can create one manually using the usermod command.

If you have further questions or need additional details, feel free to ask!

0 Comments

no data
Be the first to share your comment!