selinux

时间:2020-10-27 11:30:56   收藏:0   阅读:40
yum provides semanage
yum install -y policycoreutils-python

getenforce
sestatus
setenforce   

 /etc/selinux/config 
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.

修改文件的SELinux标签的命令:chcon ;restorecon

chcon [option]...  CONTXT  /path/to/file...  #直接对指定的文件写完整的安全上下文字段

chcon [option]...  [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...  #根据上下文类型更改

chcon [option]...  --reference=RFILE  FILE....  #参考RFILE的上下文修改FILE的上下文

-R :如果是目录,将同时递归设置该目录下所有文件

restorencon  [option]  /path/to/somewhere

               -R:递归恢复处理

semanage fcontext  -l
semanage fcontext -a -t httpd_sys_content_t ‘/testdir(/.*)?’
semanage fcontext -d -t httpd_sys_content_t ‘/testdir(/,*)?’

semanage port -l
semanage port -a -t http_port_t -p tcp 9527
semanage port -d -t http_port -t -p tcp 9527
semanage port -m -t http_port_t -p tcp 9527
ls -lrZ

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!