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