Exploring the /etc directory: The skel directory

Exploring the /etc directory: The skel directory

In this tutorial we will learn about exploring the /etc directory: The skel directory in Linux.

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.

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

Enjoyed this video?
Exploring the /etc directory: The skel directory
"No Thanks. Please Close This Box!"