selinux

1. 查看selinux状态

SELinux的状态:

  • enforcing:强制,每个受限的进程都必然受限

  • permissive:允许,每个受限的进程违规操作不会被禁止,但会被记录于审计日志

  • disabled:禁用

相关命令:

  • getenforce: 获取selinux当前状态

  • sestatus :查看selinux状态

  • setenforce 0|1    0设置为 permissive   1设置为 enforcing

[root@localhost html]#getenforce 
Enforcing
 
 
如果没有开启可以使用以下命令开启
[root@localhost html]#setenforce 1
 
 
永久开启需要修改  此处文件  /etc/selinux/config
vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing

2.文件类型 :

3.seinfo:


[root@localhost ~]# seinfo -a     #查看上下文件的控制类型

 4.修改文件类型:

4.1查看httpd进程:

[root@localhost html]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 index.html
[root@localhost html]# 
[root@localhost html]# ps auxZ|grep httpd ###过滤httpd进程
system_u:system_r:httpd_t:s0    root      51859  0.0  0.2 221952  4996 ?        Ss   13:50   0:00 /usr/sbin/httpd -DFOREGROUND
system_u:system_r:httpd_t:s0    apache    51860  0.0  0.1 224036  3104 ?        S    13:50   0:00 /usr/sbin/httpd -DFOREGROUND
system_u:system_r:httpd_t:s0    apache    51861  0.0  0.1 224036  3104 ?        S    13:50   0:00 /usr/sbin/httpd -DFOREGROUND

4.2.用7-1curl访问7-2:

4.3.在7-2中修改文件类型 :

[root@localhost html]# chcon -t var_t /var/www/html/index.html
[root@localhost html]# 
[root@localhost html]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:var_t:s0   index.html
[root@localhost html]# 

 更改查看:

4.4.开一下selinux:

4.5.用7-1再去访问index.html页面:

报错了

4.6.把selinux关掉:

又可以了 

5.去7-3改端口:

1.先把selinux开启:

2.去主配置文件中加端口: 

3.解决进程与端口绑定问题

6.selinux的配置文件:

[root@localhost html]# vim /etc/selinux/config

 

相关推荐

  1. <span style='color:red;'>selinux</span>

    selinux

    2024-03-15 14:00:07      22 阅读
  2. <span style='color:red;'>SELinux</span>

    SELinux

    2024-03-15 14:00:07      19 阅读
  3. 9.<span style='color:red;'>SELinux</span>

    9.SELinux

    2024-03-15 14:00:07      21 阅读
  4. SELinux简介

    2024-03-15 14:00:07       9 阅读
  5. SELinux refpolicy详解(9)

    2024-03-15 14:00:07       55 阅读
  6. SELinux refpolicy详解(13)

    2024-03-15 14:00:07       44 阅读
  7. SELinux 关闭修改

    2024-03-15 14:00:07       56 阅读
  8. 什么是Selinux

    2024-03-15 14:00:07       37 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-15 14:00:07       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-15 14:00:07       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-15 14:00:07       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-15 14:00:07       20 阅读

热门阅读

  1. vue和js常识

    2024-03-15 14:00:07       19 阅读
  2. LeetCode hot100-11

    2024-03-15 14:00:07       19 阅读
  3. C#学习汇总

    2024-03-15 14:00:07       22 阅读
  4. DP-力扣 120.三角形最小路径和

    2024-03-15 14:00:07       16 阅读
  5. C++由动态链接库dll生成lib文件

    2024-03-15 14:00:07       20 阅读
  6. Filebeat rpm方式安装及配置

    2024-03-15 14:00:07       22 阅读
  7. ESP32 域名解析得到IP地址

    2024-03-15 14:00:07       22 阅读