当前位置: > CentOS > CentOS入门 >

CentOS系统中修改目录的权限后恢复

时间:2014-02-24 16:01来源:linux.it.net.cn 作者:IT网

在我工作中的某一天执行了chmod -R 777 /home后我十分后悔,这下不知道该怎么办?心里面很是着急。此时灵机一动问了一下谷哥,终于找到了方法解决此问题,不过前提是要自己做了文件权限备份工作,现在我就给大家讲解一下我处理的过程:

    1.今天我就用/home/tong目录做实验,查看/home/tong目录和文件现有的权限

       [root@redhat1 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目录用目录下的文件权限(注意不要在要备份的目录下进行此命令,最好是在目录的上一级进行操作,写相对路径)

       [root@redhat1 ~]# cd /home/

       [root@redhat1 home]# getfacl  -R tong/ > 11.bak        --将文件权限备份并保存到一个文件中
       getfacl: Removing leading '/' from absolute path names
       [root@redhat1 home]#

    3.修改目录权限并查看权限是否修改

       [root@redhat1 home]# chmod  -R 777 tong/       --修改目录及文件权限
       [root@redhat1 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
       [root@redhat1 home]#

    4.还原目录和文件权限

       [root@redhat1 home]# setfacl  --restore=11.bak     --还原目录及文件权限
       [root@redhat1 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
       [root@redhat1 home]#

(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容