How To Create User Creation Defaults With Skel In Linux?
We want to create system default for user creation and addition. System defaults mean what will be default values for the user creation like home path, user id etc.
/etc/skel is the directory where files will be copied to the new user directory from here. If we look detailed we will see that there are some default files in it.
$ls -al /etc/skel/
drwxr-xr-x. 2 root root 59 Eyl 5 11:53 .
drwxr-xr-x. 86 root root 8192 Kas 8 11:28 ..
-rw-r--r--. 1 root root 18 Ağu 2 16:00 .bash_logout
-rw-r--r--. 1 root root 193 Ağu 2 16:00 .bash_profile
-rw-r--r--. 1 root root 231 Ağu 2 16:00 .bashrc
All these .bashrc .bash_logout and .bash_profile files will be copied newly created user home directory.
.bashrc is the start file when a new shell is opened it will run. For example if we want to run some command while opening new shell or we want to set some environment variables we will add them to this files.
.bash_profile is the file which will call .bashrc file and set some PATH environment
Create Some File In Skel
Keep i mind that to create files in skel we need root privileges. If we want to set some mail related envonmrent variables we can edit .bash_profile file like below.
$echo "mail=192.168.1.10" >> /etc/skel/.bashrc