I want to know where should I use useradd -m or useradd -d to make a new home directory? I didn't get the purpose of -m and -d flag in useradd?


I'm going to assume you read the manual (man useradd), which says

-d, --home HOME_DIR The new user will be created using HOME_DIR as the value for the user's login directory [...]


-m, --create-home Create the user's home directory if it does not exist [...]

As it says, the --home flag defines the entry in the user database (/etc/passwd) and --create-home creates the directory.

In a typical single user home environment you'd probably want the --create-home flag, leaving the other at its default value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.