语法格式
semanage [参数]
常用参数:
-l | 查询 |
---|---|
-a | 增加,你可以增加一些目录的默认安全上下文类型设置 |
-m | 修改 |
-d | 删除 |
参考实例
查询一下/var/www/html的默认安全性本文的设置:
[root@linux265 ~]# semanage fcontext -l
用semanage命令设置 /srv/samba 目录的默认安全性本文为public_content_t:
[root@linux265 ~]# mkdir /srv/samba ll -Zd /srv/samba drwxr-xr-x root root root:object_r:var_t /srv/samba
如上所示,默认的情况应该是 var_t :
[root@linux265 ~]# semanage fcontext -l | grep '/srv' /srv/.* all files system_u:object_r:var_t:s0 /srv/([^/]*/)?ftp(/.*)? all files system_u:object_r:public_content_t:s0 /srv/([^/]*/)?www(/.*)? all files system_u:object_r:httpd_sys_content_t:s0 /srv/([^/]*/)?rsync(/.*)? all files system_u:object_r:public_content_t:s0 /srv/gallery2(/.*)? all files system_u:object_r:httpd_sys_content_t:s0 /srv directory system_u:object_r:var_t:s0
上面则是默认的 /srv 底下的安全性本文资料,不过,并没有指定到 /srv/samba:
[root@linux265 ~]# semanage fcontext -a -t public_content_t "/srv/samba(/.*)?" [root@linux265 ~]# semanage fcontext -l | grep '/srv' /srv/samba(/.*)? all files system_u:object_r:public_content_t:s0
尝试恢复默认值:
[root@linux265 ~]# restorecon -Rv /srv/samba*
至此关于Linux常用命令semanage命令的使用方法分享结束,大家如果对semanage命令的使用方法还有问题可以通过评论区将问题提交我们。
以上就是
为各位朋友分享的 相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多 等着你 !