How to Control or Disable SELinux in Fedora and CentOS Linux

For most of cases, you should not disable SELinux. However, for some users, SELinux may cause problems or is not needed. We may just make it not block operations or totally disable it.

Making SELinux log warnings instead of blocking

For many cases, people find SELinux blocks operations. For tests or some other situations, you may make it not blocking. But the warning messages of SELinux tells you many possible security problems. An good way may be making it warn you but not block operations.

SELinux’s configuration file is /etc/selinux/config

The method to configuring SELinux in Fedora is by editing the config file of SELinux:

$ cd /etc/selinux/
$ su
# cp config config.bak0
# vi config

Find this line:

SELINUX=enforcing

Change it to:

SELINUX=permissive

You will need to reboot to make it take effect.

Temporarily disable SELinux

Instead of permanently disable SELinux, you may just want to disable SELinux temporaryly. You can do this by running

# setenforce 0

As an alternative way, if you have SELinux enalbed

# echo 0 >/selinux/enforce

You can also enable SELinux back by

# setenforce 1

or

# echo 1 >/selinux/enforce

Permanently disable SELinux

If you would not to see SELinux forever, you may disable it permanently.

The method to diable SELinux in Fedora:

$ cd /etc/selinux/
$ su
# cp config config.bak0
# vi config

Find this line:

SELINUX=enforcing

Change it to:

SELINUX=disabled

Checking SELinux status

After configuring SELinux, you may want to check the status of SELinux. Here are several ways.

$ selinuxenabled
$ echo $?
1

Here, the return value of selinuxenabled indicates its status: ‘1’ means disabled and ‘0’ means enabled. This is very useful for scripts.

$ sestatus
SELinux status:                 disabled

sestatus shows human friendly results showing the status.

$ getenforce 
Disabled

getenforce is like sestatus but shows only the status with a word.

Update on Apr. 29, 2015: add more options for controlling and disabling SELinux.

Similar Posts

  • Fedora 中文字体设置

    Fedora 一直有中文字体难看的问题, 尤其是在英文环境中. 使用本文中的配置方法可以得到令人满意的中文效果. 此方案中使用字体都为开源且在Fedora源中自带. 此方案对 Fedora 9 – 20 有效. 对于后续版本支持我会确认并更新此文章. 此方案对Gnome, KDE都有效. Firefox 中也有中文难看的问题, 后面会提到. 快速配置方法 如果你想马上配置好,请使用如下命令。此方法测试使用效果良好。 # yum install cjkuni-ukai-fonts cjkuni-uming-fonts # wget https://raw.githubusercontent.com/zma/config_files/master/others/local.conf \ -O /etc/fonts/local.conf 相关英文字体配置可以参考:Improving Fedora Font Rendering with Open Software and Fonts Only. Fedora 系统中文字体的配置方案 使用uming和ukai字体,即AR PL UMing CN等. 中文字体和等宽字体效果如图所示(点击看大图, Firefox 中文字体设置在后面会提到). 方法如下: 安装字体 首先安装这两个字体: cjkuni-ukai-fonts cjkuni-uming-fonts (在Fedora…

  • How to get the file extension from a filename in Python?

    How to get the file extension from a filename in Python? For example, I would like to get “.txt” from “file.txt”. The Python code: >>> name, ext = os.path.splitext(‘file.txt’) >>> name ‘file’ >>> ext ‘.txt’ Manual of os.path.splitext: https://docs.python.org/2/library/os.path.html#os.path.splitext Read more: How to get file extension in JavaScript? Set Chrome RSS Subscription Extension to Subscribe…

  • |

    What Are the Secrets Behind Google’s Success Story?

    Google has created an image that tells us its core values are centered around innovation. There are very few companies that can boast a similar level of influence as Google. Nevertheless, we should not only focus on Google’s achievements today but also learn from their journey to the top. We can break down Google’s core…

3 Comments

  1. Pingback: 配置Diskful Server | 撤退的逃兵

Leave a Reply

Your email address will not be published. Required fields are marked *