Hello All,

In this post we are going to explore the directory `/etc/skel` under Linux. This directory is responsible to make all the users to get default path i.e., $PATH (where ‘bash_profile’ is there). The content of this directory will be copied to the home directory of the user whenever user is created using ‘useradd’ or ‘adduser’.

Yeah, your insight is on the correct track, from this directory(/etc/skel) “.bash_logout”, “.bash_profile” and “.bashrc” files will be copied to the home directory of the user. Whenever we create any user all the files from /etc/skel will be copied to the home direcotry of the user. This is the default action of useradd, if not specified otherwise.

Lets go little deeper into it,

How Can I override the default skel directory ?

There is a file `/etc/default/useradd`. We can change the skel directory path(Edit the Line number 8 to have your customized skel directory).

# Begin /etc/default/useradd
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=
SKEL=/etc/skel

Now I created a file called ‘myright.txt` under /etc/skel directory. In that file I have some instruction like do’s and don’ts of the server.

 


On next step We create user named ‘pelister’ and check on the home directory of the user. We can notice that `myright.txt` file is there.

 

Summary :

  • All the files from the /etc/skel directory will be copied to the home directory of the user, whenever we create a new user.
  • We can also override the default skel directory by using the file ‘/etc/default/useradd’.
  • In the above Example we use the skel directory to send the ‘myright.txt’ to the newuser.
Linux : /etc/skel Directory

Leave a Reply

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