Linux will copy the the contents of /etc/skel when a new user is created. I want to have a sub-directory in each user's home directory, MyStevedore. I want this directory to have the owner be the new user and the group to be the group stevedore with the permissions drwxrwxr-x. The user is not a member of the group stevedore.

  • 1
    what Linux distribution are you running?
    – Ash Palmer
    Commented Oct 27, 2010 at 20:04
  • 2
    And the reason the distro matters is because depending on the distro and how you are creating users there are methods to extend the user creation tools to run a script of your choosing. For example on Debian-based systems /usr/local/sbin/adduser.local will be called when you run adduser to create an account.
    – Zoredache
    Commented Oct 27, 2010 at 20:17
  • this is where a little script-fu wrapped around useradd might do the trick. Certain other distro's have 'adduser' which is a bash script doing just that!
    – Ash Palmer
    Commented Oct 27, 2010 at 20:30

2 Answers 2


Assuming you're using adduser to create the user, it will do most of the job, assuming you've created a directory /etc/skel/MyStevedore with your desired permissions. However on most systems ~/MyStevedore will always belong to the user's primary group.

On Debian and derivatives (including Ubuntu), once adduser has created the user, it calls /usr/local/sbin/adduser.local if it exists. You can use it to complete the job.

username=$1 uid=$2 gid=$3 home_dir=$4
if [ -d "$home_dir/MyStevedore" ]; then
  chgrp stevedore "$home_dir/MyStevedore"

You could add an if statement to the .bash_profile script in /etc/skel that will check if the folder exists. If it doesn't exist it will create it and set the permissions.

The first time a new user logs in the folder will be created.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .