is it possible to create an additional directory when creating a user in linux?

Lets say i add a new user named suzi. When I do that, I want to create a home directory as usual under /home/suzi and in addition I would like to create another directory under /work/suzi/ which she owns and she could create her work stuff in.

People browsing the /work directory should only be able to access their own stuff ofc under /work/$USER

  • 1
    Did you get it to work yet? – Lenniey Apr 28 '17 at 11:24

man adduser:

If the file /usr/local/sbin/adduser.local exists, it will be executed after the user account has been set up in order to do any local setup. The arguments passed to adduser.local are: username uid gid home-directory The environment variable VERBOSE is set according to the following rule:

0 if --quiet is specified

1 if neither --quiet nor --debug is specified

2 if --debug is specified

(The same applies to the variable DEBUG, but DEBUG is deprecated and will be removed in a later version of adduser.)

This should be exactly what you want. (If you are on a Debian distro at least)

Edit: or if it's OK to add the directory in /home/username/workor whatever, you can use SKEL:

adduser will copy files from SKEL into the home directory and prompt for finger (gecos) information and a password. The gecos may also be set with the --gecos option. With the --disabled-login option, the account will be created but will be disabled until a password is set. The --disabled-password option will not set a password, but login is still possible (for example with SSH RSA keys).

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.