CentOS系統中修改目錄的許可權後恢複

來源:互聯網
上載者:User

標籤:

在我工作中的某一天執行了chmod -R 777 /home後我十分後悔,這下不知道該怎麼辦?心裏面很是著急。此時靈機一動問了一下穀哥,終於找到了方法解決此問題,不過前提是要自己做了檔案許可權備份工作,現在我就給大家講解一下我處理的過程:

    1.今天我就用/home/tong目錄做實驗,查看/home/tong目錄和檔案現有的許可權

       [[email protected] home]# ll /home/tong/
       total 0
       -rw-r--r--. 1 root root 0 Dec  4 09:45 1.txt
       -rw-r--r--. 1 root root 0 Dec  4 09:45 2.txt

     2.備份/home/tong目錄用目錄下的檔案許可權(注意不要在要備份的目錄下進行此命令,最好是在目錄的上一級進行操作,寫相對路徑)

       [[email protected] ~]# cd /home/

       [[email protected] home]# getfacl  -R tong/ > 11.bak        --將檔案許可權備份並儲存到一個檔案中
       getfacl: Removing leading ‘/‘ from absolute path names
       [[email protected] home]#

    3.修改目錄許可權並查看許可權是否修改

       [[email protected] home]# chmod  -R 777 tong/       --修改目錄及檔案許可權 
       [[email protected] home]# ll /home/tong/                   --查看檔案許可權
       total 0
       -rwxrwxrwx. 1 root root 0 Dec  4 09:45 1.txt
       -rwxrwxrwx. 1 root root 0 Dec  4 09:45 2.txt
       [[email protected] home]#

    4.還原目錄和檔案許可權

       [[email protected] home]# setfacl  --restore=11.bak     --還原目錄及檔案許可權
       [[email protected] home]# ll tong/              --成功了,也祝大家成功
       total 0
       -rw-r--r--. 1 root root 0 Dec  4 10:16 1.txt
       -rw-r--r--. 1 root root 0 Dec  4 10:16 2.txt
       [[email protected] home]#

 

轉自:http://www.centoscn.com/CentOS/config/2014/0120/2387.html

CentOS系統中修改目錄的許可權後恢複

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.