Can I force overwrite the directory?

QuestionsQuestions8 SkillsProUser Account ManagementAug, 28 2025
0113

The useradd command does not provide a direct option to forcefully overwrite an existing home directory. If you want to create a new user and ensure that the existing home directory is replaced, you will need to manually remove the existing directory before running the useradd command.

Here’s how you can do it:

  1. Remove the existing directory (be cautious, as this will delete all contents within it):

    rm -rf /home/username
  2. Then, create the user with the -m option:

    useradd -m username

This will create a new home directory for the user. Make sure to back up any important data before deleting the existing directory.

0 Comments

no data
Be the first to share your comment!