The Unix and Linux skeleton directory: /etc/skel

What is the /etc/skel directory?

The /etc/skel directory contains files and folders that will be copied in the new user’s home directory (login directory), when that user is created with useradd or other commands.

The skeleton directory, /etc/skel, allows the administrator (the root user) to create new users having the same files and folders in their home directories.

By default, some configuration files are usually placed in the /etc/skel directory after the operating system is installed:

  • /etc/skel/.bash_logout
  • /etc/skel/.bashrc
  • /etc/skel/.profile
  • /etc/skel/.vimrc

When a user is deleted, the data inside the /etc/skel directory remains unchanged.

To change the default location of the skeleton directory, edit the line beginning with SKEL=, in the /etc/default/useradd file. By default, the skeleton directory is /etc/skel :

$ grep SKEL /etc/default/useradd
# The SKEL variable specifies the directory containing "skeletal" user
# SKEL=/etc/skel

Sample /etc/skel content:

$ ls -lA /etc/skel
-rw-r--r-- 1 root root 220 2011-05-18 13:00 .bash_logout
drwxr-xr-x 3 root root 4096 2011-10-24 15:19 .config
drwxr-xr-x 4 root root 4096 2011-11-09 20:56 .mozilla
-rw-r--r-- 1 root root 675 2011-05-18 13:00 .profile

Testing how the skeleton directory works:

$ sudo su
# cd /etc/skel
# mkdir workdir
# touch script1 script2
# ls
script1 script2 workdir
# useradd -m -d /home/testdir test9
# ls /home/testdir
script1 script2 workdir

Share and Enjoy

  • Twitter
  • Facebook
  • Google Plus
  • Email
  • RSS
Tagged with: , , ,
Posted in The Linux and Unix Articles!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe

  

Subscribe to get the latest Linux news and how to guides directly on your e-mail!