The/etc/skel directory in Linux (Skel is the abbreviation for skeleton, meaning bones, frames. ) is the directory used to store the new user profile, when we add a new user, all files in this directory are automatically copied to the newly added user's home directory, by default, all files under the/etc/skel directory are hidden files (files that begin with a. dot); Modify, add, delete etc /skel directory, we can provide a unified, standard, and initialized user environment for newly created users.
Demo: Allow every new user to see Hi.txt's Documents
[[email protected] ~]# ll /etc/skel/ -al view files under/etc/skel/Total 20drwxr-xr-x. 2 root root 4096 feb  23 14:39 .DRWXR-XR-X. 59 ROOT ROOT 4096 APR 19 12:03&NBSP, .... -rw-r--r--. 1 root root 18 jul 18 2013 .bash_ Logout-rw-r--r--. 1 root root 176 jul 18 2013 .bash_ Profile-rw-r--r--. 1 root root 124 jul 18 2013 . Bashrc[[email protected] ~]# cd /etc/skel/[[email protected] skel]# ll The default view is hidden total 0[[email protected] skel]# vi hi.txt Create a Hi.txt file, write hellohello[[email protected] skel]# lltotal 4-rw-r--r--. 1 root root 6 apr 21 11:22 hi.txt[[email protected] skel]# useradd test1 new Test1 User [[Email protected] skel]# ll /home/test1/ -al View TEst1 's home directory total 24drwx------. 2 test1 test1 4096 apr 21 11:23 . DRWXR-XR-X. 5 ROOT  ROOT  4096 APR 21 11:23&NBSP, .... -rw-r--r--. 1 test1 test1 18 jul 18 2013 .bash_ Logout-rw-r--r--. 1 test1 test1 176 jul 18 2013 .bash_ Profile-rw-r--r--. 1 test1 test1 124 jul 18 2013 . Bashrc-rw-r--r--. 1 test1 test1 6 Apr 21 11:22 hi.txt See the Hi.txt file you just created [[Email protected] skel]# cat /home/test1/hi.txt can see the hello content inside hello
Simulate the deletion of files after test1 user/etc/skel/directory
Delete: File under/etc/skel/[[email protected] skel]# su - test1[[email protected] ~]$  LS -ALTOTAL 24DRWX------. 2 test1 test1 4096 apr 21 11:23  .DRWXR-XR-X. 5 ROOT  ROOT  4096 APR 21 11:23&NBSP, .... -rw-r--r--. 1 test1 test1 18 jul 18 2013 .bash_ Logout-rw-r--r--. 1 test1 test1 176 jul 18 2013 .bash_ Profile-rw-r--r--. 1 test1 test1 124 jul 18 2013 . Bashrc-rw-r--r--. 1 test1 test1 6 Apr 21 11:22 hi.txt[[email protected] ~]$ rm -f * Direct Delete no use [[email protected] ~]$ ls -al files are still in total 20drwx------. 2 test1 test1 4096 Apr 21 11:51 .DRWXR-XR-X. 5 ROOT  ROOT  4096 APR 21 11:23&NBSP, .... -rw-r--r--. 1 test1 test1 18 jul 18 2013 .bash_ Logout-rw-r--r--. 1 test1 test1 176 jul 18 2013 .bash_ Profile-rw-r--r--. 1 test1 test1 124 jul 18 2013 .bashrc[[ email protected] ~]$ rm -f .* delete files that begin with. rm: cannot remove '. ': is a directoryrm: cannot remove ': Is a directory[[email protected] ~]$ ls -al Files such as .bash have been deleted total 8drwx------. 2 test1 test1 4096 apr 21 11:52 .drwxr-xr-x. 5 root root 4096  APR 21 11:23&NBSP, .... [[email protected] ~]$ su - test1 switch to test1 user password: -bash-4.1$ appears because of/etc/skel/ The file under the-bash-4.1$ -bash-4.1$ logout recovery/etc/skel/file [[email protected] ~]# cd /etc/ skel/ switch to ROOT to open the/etc/skel/directory [[Email protected] skel] # ls -altotal 24drwxr-xr-x. 2 root root 4096 apr 21 11:22 .DRWXR-XR-X. 59 ROOT ROOT 4096 APR 21 11:50&NBSP, .... -rw-r--r--. 1 root root 18 jul 18 2013 .bash_ Logout-rw-r--r--. 1 root root 176 jul 18 2013 .bash_ Profile-rw-r--r--. 1 root root 124 jul 18 2013 . Bashrc-rw-r--r--. 1 root root 6 apr 21 11:22 hi.txt[[email protected] skel]# cp -a .bash* /home/test1/ Copy all. bash files to Test1 's home directory [[email protected] skel]# ll /home/test1/ -al view file already exists total  20DRWX------. 2 test1 test1 4096 Apr 21 11:59 .drwxr-xr-x. 5 ROOT  ROOT  4096 APR 21 11:23&NBSP, .... -rw-r--r--. 1 root root 18 jul 18 2013 . bash_logout permissions only belong to Root-rw-r--r--. 1 root Root 176 jul 18 2013 .bash_profile-rw-r--r--. 1 root root 124 jul 18 2013 .bashrc[[email protected] skel]# chown -r test1 /home/test1/ Assign to Test1 user rights, do not assign rights cannot be used [[Email protected] skel]# ll /home/test1/ -al total 20drwx------. 2 test1 test1 4096 apr 21 11:59 . DRWXR-XR-X. 5 ROOT  ROOT  4096 APR 21 11:23&NBSP, .... -rw-r--r--. 1 test1 root 18 jul 18 2013 .bash_ logout permissions assigned to test1-rw-r--r--. 1 test1 root 176 jul 18 2013 .bash_profile-rw-r--r--. 1 test1 root 124 jul 18 2013 .bashrc[[email protected] skel]# su - test1 switch to Test1 user, already available [[email protected] ~]$ [[email protected] ~]$
Learn from:
Old boy Education
This article is from the blog "Write to Yourself", so be sure to keep this source http://zhaodongwei.blog.51cto.com/4233742/1766148
Linux/etc/skel Directory