How To - Set the default content of a new user's home directory using /etc/skel

When you create a user account on a Linux system and ask it to create a home directory, some files are automatically added to it e.g. - .bashrc, .bash_history etc. How does that happen or how can I add/remove files to a user's home during the creation of his account? This is all taken care of by the /etc/skel directory.

The name /etc/skel is probably derived for the term "skeleton". This directory is responsible for the default structure or skeleton of a user's home folder.

When we create a new user using the useradd command along with -m option(to create a home folder), all the contents of the directory /etc/skel are copied to the new user's home folder. Adduser command does the same thing.

You can even mention a different skeleton directory by editing the configuration file - /etc/default/useradd

SKEL=/etc/skel

or, by mentioning the path of the skeleton directory when you enter the command.

useradd -k /path/to/new/skel

Typically, the files contained in it are mostly configuration files of:

bash - .bashrc, .bash_history, .bash_profile, .inputrc

vim - .vimrc

The number of files in /etc/skel are usually kept low because its always easier to maintain a common behavior or config across the whole system by modifying global configuration files e.g /etc/vim/vimrc, /etc/profile etc. rather than maintaining a different one for every user.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.