- 1.semanage fcontext -l 查看所有系统定制的的selinux类型
- semanage fcontext -l | grep "/var/www/(.*)?"查看/VAR/WWW下面的文件包含的上下文类型
- mv保留原来的类型 cp会改变 cp -a不会改变
- 2.新建的/test
- semanage fcontext -a -f "" -t httpd_sys_content_t '/test(/.*)?'
- [root@server76 test]# ll -Z
- drwxr-xr-x+ root root unconfined_u:object_r:file_t:s0 aa
- -rw-rw-r--+ root root unconfined_u:object_r:file_t:s0 file
- drwx------. root root system_u:object_r:file_t:s0 lost+found
- [root@server76 test]# res
- reset resize2fs resizecons restart restorecon restorecond
- [root@server76 test]# restorecon -Rv .
- restorecon reset /test context system_u:object_r:file_t:s0->system_u:object_r:httpd_sys_content_t:s0
- restorecon reset /test/lost+found context system_u:object_r:file_t:s0->system_u:object_r:httpd_sys_content_t:s0
- restorecon reset /test/file context unconfined_u:object_r:file_t:s0->unconfined_u:object_r:httpd_sys_content_t:s0
- restorecon reset /test/aa context unconfined_u:object_r:file_t:s0->unconfined_u:object_r:httpd_sys_content_t:s0
本文转自 369蓝宝 51CTO博客,原文链接:http://blog.51cto.com/3739387/1130095,如需转载请自行联系原作者