How can a home directory be created manually?

QuestionsQuestions4 SkillsProDec, 11 2025
0172

That's a very practical question! While useradd -m is convenient, knowing how to do it manually is super useful.

To manually create a home directory, you generally follow these steps:

  1. Create the directory: Use mkdir to create the directory itself. For example, for a user named charlie:

    sudo mkdir /home/charlie
    
  2. Set ownership: The home directory needs to be owned by the user it belongs to. Use chown to change the ownership.

    sudo chown charlie:charlie /home/charlie
    

    (This assumes the user charlie and a group charlie already exist. If only the user exists, you might just do chown charlie /home/charlie or chown charlie:users /home/charlie depending on your system's group strategy.)

  3. Set permissions: Assign appropriate permissions so the user can read, write, and execute (access) files within their own home directory, and others have limited or no access. A common set of permissions for a home directory is 700 or 750.

    sudo chmod 700 /home/charlie
    
    • 700 means only the owner (charlie) has full read, write, and execute permissions.
    • 750 means the owner (charlie) has full permissions, and the group (charlie) has read and execute permissions, but no others can access it.

So, for a new user named charlie (assuming you've already created the user account without a home directory first, e.g., sudo useradd charlie), the full manual process would look like this:

sudo mkdir /home/charlie
sudo chown charlie:charlie /home/charlie
sudo chmod 700 /home/charlie

After these steps, charlie would have a proper home directory!

Do you want to try creating a user and their home directory manually?

0 Comments

no data
Be the first to share your comment!