What if the home directory already exists?

QuestionsQuestions8 SkillsProUser Account ManagementSep, 29 2025
0181

If the home directory already exists when you use the useradd -m command, the command will not create a new home directory. Instead, it will use the existing directory as the user's home directory. However, it will not modify the contents of the existing directory.

If you want to ensure that the home directory is created only if it does not already exist, you can use the -M option along with -m. The -M option prevents the creation of a home directory if one already exists.

Here's an example:

useradd -m -M username

In this case, if /home/username already exists, the command will not attempt to create it again.

0 Comments

no data
Be the first to share your comment!