The command useradd new will create the /home/new directory.

Is there a way to create the /home/new and /home/new/check directories when useradd new is executed?

I don't want to write two commands for the job every time I create a new user.

useradd new
mkdir /home/new/check
  • In additon to the answer below about putting files/directories in /etc/skel consider using adduser instead of useradd - unless you are creating accounts with a script... – ivanivan Oct 30 '17 at 11:59

The template used when creating a new home directory is in /etc/skel. Simply create the directory there and all new users will have it.

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.