Linux /etc/skel目录
生活随笔
收集整理的這篇文章主要介紹了
Linux /etc/skel目录
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
? Linux中的/etc/skel目錄(skel是skeleton的縮寫(xiě),意為骨骼、框架。)是用來(lái)存放新用戶(hù)配置文件的目錄,當(dāng)我們添加新用戶(hù)時(shí),這個(gè)目錄下的所有文件會(huì)自動(dòng)被復(fù)制到新添加的用戶(hù)的家目錄下;默認(rèn)情況下,/etc/skel目錄下的所有文件都是隱藏文件(以.點(diǎn)開(kāi)頭的文件);通過(guò)修改、添加、刪除/etc/skel目錄下的文件,我們可為新創(chuàng)建的用戶(hù)提供統(tǒng)一、標(biāo)準(zhǔn)的、初始化用戶(hù)環(huán)境。
?
演示:讓每個(gè)新用戶(hù)都可以看到hi.txt的文檔
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | [root@w?~]#?ll?/etc/skel/?-al????????????????????????????查看/etc/skel/下的文件 total?20 drwxr-xr-x.??2?root?root?4096?Feb?23?14:39?. drwxr-xr-x.?59?root?root?4096?Apr?19?12:03?.. -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 [root@w?~]#?cd?/etc/skel/ [root@w?skel]#?ll????????????????????????????????????????默認(rèn)查看都是隱藏的 total?0 [root@w?skel]#?vi?hi.txt?????????????????????????????????創(chuàng)建一個(gè)hi.txt的文件,寫(xiě)入hello hello [root@w?skel]#?ll total?4 -rw-r--r--.?1?root?root?6?Apr?21?11:22?hi.txt [root@w?skel]#?useradd?test1?????????????????????????????新建test1的用戶(hù) [root@w?skel]#?ll?/home/test1/?-al???????????????????????查看test1的家目錄 total?24 drwx------.?2?test1?test1?4096?Apr?21?11:23?. drwxr-xr-x.?5?root??root??4096?Apr?21?11:23?.. -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???????看到剛才創(chuàng)建的hi.txt文件 [root@w?skel]#?cat?/home/test1/hi.txt????????????????????可以看到里面的hello內(nèi)容 hello |
模擬刪除test1用戶(hù)/etc/skel/目錄下的文件后的恢復(fù)
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | 刪除:/etc/skel/下的文件 [root@w?skel]#?su?-?test1 [test1@w?~]$?ls?-al total?24 drwx------.?2?test1?test1?4096?Apr?21?11:23?. drwxr-xr-x.?5?root??root??4096?Apr?21?11:23?.. -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 [test1@w?~]$?rm?-f?*???????????????????????????????直接刪除不管用 [test1@w?~]$?ls?-al????????????????????????????????文件還在 total?20 drwx------.?2?test1?test1?4096?Apr?21?11:51?. drwxr-xr-x.?5?root??root??4096?Apr?21?11:23?.. -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 [test1@w?~]$?rm?-f?.*??????????????????????????????刪除以.開(kāi)頭的文件 rm:?cannot?remove?`.':?Is?a?directory rm:?cannot?remove?`..':?Is?a?directory [test1@w?~]$?ls?-al????????????????????????????????.bash等文件已刪除 total?8 drwx------.?2?test1?test1?4096?Apr?21?11:52?. drwxr-xr-x.?5?root??root??4096?Apr?21?11:23?.. [test1@w?~]$?su?-?test1????????????????????????????切換到test1用戶(hù) Password:? -bash-4.1$?????????????????????????????????????????出現(xiàn)這種是因?yàn)?etc/skel/下的文件沒(méi)了 -bash-4.1$? -bash-4.1$?logout 恢復(fù)/etc/skel/文件 [root@w?~]#?cd?/etc/skel/??????????????????????????切換到root,打開(kāi)/etc/skel/目錄 [root@w?skel]#?ls?-al total?24 drwxr-xr-x.??2?root?root?4096?Apr?21?11:22?. drwxr-xr-x.?59?root?root?4096?Apr?21?11:50?.. -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 [root@w?skel]#?cp?-a?.bash*?/home/test1/???????????把所有.bash的文件復(fù)制到test1的家目錄 [root@w?skel]#?ll?/home/test1/?-al?????????????????查看文件已存在 total?20 drwx------.?2?test1?test1?4096?Apr?21?11:59?. drwxr-xr-x.?5?root??root??4096?Apr?21?11:23?.. -rw-r--r--.?1?root??root????18?Jul?18??2013?.bash_logout????????權(quán)限只屬于root -rw-r--r--.?1?root??root???176?Jul?18??2013?.bash_profile -rw-r--r--.?1?root??root???124?Jul?18??2013?.bashrc [root@w?skel]#?chown?-R?test1?/home/test1/?????????賦于test1用戶(hù)權(quán)限,不賦權(quán)不能使用 [root@w?skel]#?ll?/home/test1/?-al?????????????? total?20 drwx------.?2?test1?test1?4096?Apr?21?11:59?. drwxr-xr-x.?5?root??root??4096?Apr?21?11:23?.. -rw-r--r--.?1?test1?root????18?Jul?18??2013?.bash_logout????????權(quán)限賦給test1了 -rw-r--r--.?1?test1?root???176?Jul?18??2013?.bash_profile -rw-r--r--.?1?test1?root???124?Jul?18??2013?.bashrc [root@w?skel]#?su?-?test1??????????????????????????切換到test1用戶(hù),已經(jīng)可以了 [test1@w?~]$? [test1@w?~]$ |
本文轉(zhuǎn)自cix123 ?51CTO博客,原文鏈接:http://blog.51cto.com/zhaodongwei/1766148,如需轉(zhuǎn)載請(qǐng)自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的Linux /etc/skel目录的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Django之部署NGINX+uWSGI
- 下一篇: 迅速掌握Unix编程