Understanding the /etc/skel directory in Linux

The skel directory

Directory /etc/skel/ (skel is derived from the “skeleton”) is used to initiate home directory when a user is first created. A sample layout of “skeleton” user files is as shown below:

# ls -lart /etc/skel
total 32
drwxr-xr-x    4 root root  4096 Feb  4  2016 .mozilla
-rw-r--r--    1 root root   124 Feb 15  2017 .bashrc
-rw-r--r--    1 root root   176 Feb 15  2017 .bash_profile
-rw-r--r--    1 root root    18 Feb 15  2017 .bash_logout
drwxr-xr-x.   3 root root  4096 Aug 22  2017 .
drwxr-xr-x. 112 root root 12288 Feb 26 03:09 ..
Note: “skeleton” directory is defined in /etc/default/useradd file.

Below is a sample /etc/defualt/useradd file which defines the skel directory. You can change the default location /etc/skel to any other location.

# cat /etc/default/useradd
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

You can also change the default base home directory (which is “/home” in the above example) to any other location.

Default permission of /etc/skel directory

– Default permission of /etc/skel is drwxr-xr-x.
– It is not recommended to change the permission of skel directory or its contents. Changing the permission may possibly break some of the program, because in skel directory there are some profiles that needs the permission of read and trying to give it permission of execute will cause some programs/profiles to work unexpectedly.

Related Post