Linux常用命令semanage怎么用

发布时间:2022-02-17 11:18:09 作者:小新
来源:亿速云 阅读:240

小编给大家分享一下Linux常用命令semanage怎么用,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

Linux常用命令semanage命令是用来查询与修改SELinux默认目录的安全上下文。

Linux常用命令semanage怎么用

语法格式

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怎么用”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

推荐阅读:
  1. 怎样使用semanage管理SELinux安全策略
  2. 如何使用semanage管理SELinux安全策略

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux semanage

上一篇:Linux常用命令sendmail怎么用

下一篇:Linux常用命令scp怎么用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》