How to create a home directory for an existing user?

QuestionsQuestions8 SkillsProUser Account ManagementOct, 13 2025
0202

To create a home directory for an existing user, you can use the usermod command with the -d option. Here’s how to do it:

  1. Open your terminal.

  2. Run the following command, replacing username with the actual username and /home/username with the desired home directory path:

sudo usermod -d /home/username -m username
  • -d /home/username: This specifies the new home directory path.
  • -m: This option moves any existing content from the old home directory to the new one (if applicable).

For example, to create a home directory for a user named bob, you would run:

sudo usermod -d /home/bob -m bob

After executing this command, you can verify that the home directory has been created by checking its existence:

ls -ld /home/bob

This will show you the details of the newly created home directory for the user.

0 Comments

no data
Be the first to share your comment!