Automatically create folder in new users' home directory

11,273

All new users' home directories are copies of /etc/skel when the user gets created through any method that automatically creates a home directory.

If you are sure that you need the Sales folder on every new user account's home directory, you can just create the folder in /etc/skel.


Make sure the owner and permission of everything you create or modify in there is correct.

Set the permissions you want, they will be copied to the new user's home directory as they are. Usually you take 644 (octal representation) or rw-r--r-- (string representation). You can modify this with one the commands below. Make sure everything is owner-readable and all directories are owner-executable (otherwise the owner can't list or access their content).

  • sudo chmod 644 /etc/skel/FILE_OR_DIRECTORY to set permissions for a single file or directory using the octal representation.
  • sudo chmod u=rw,g=r,o=r /etc/skel/FILE_OR_DIRECTORY to set permissions for a single file or directory using a syntax similar to the string representation.
  • sudo chmod -R 644 /etc/skel to recursively set permissions for all files and directories using the octal representation.
  • sudo chmod -R u=rw,g=r,o=r /etc/skel to recursively set permissions for all files and directoriesusing a syntax similar to the string representation.

The owner should be root. You change this recursively on all files and folders in /etc/skel with the command below:

sudo chown -R root: /etc/skel
Share:
11,273

Related videos on Youtube

user_01
Author by

user_01

Updated on September 18, 2022

Comments

  • user_01
    user_01 over 1 year

    I need to automatically assign every new user that gets created a certain folder Sales in their home directory. (e.g. when you add the user tim, tim automatically gets a folder named Sales in his home directory)

    How can I do this?

    • tripleee
      tripleee over 8 years
      Unsure if this is what you are looking for but the adduser command has hooks to customize e.g. the directory layout for newly created accounts.
    • Jacob Vlijm
      Jacob Vlijm over 8 years
      Hi user_01 did you notice the answers? Could you let us know if it is helpful (or not), or if anything is clear?