SELINUXが無効化されているかどうかを確認するには、以下のコマンドを実行します。
$ getenforce
Enforcing
上記は有効になっている場合の表示で、無効化されている場合は、以下のように表示されます。
Didabled
・enforcing
SELinux機能、アクセス制御が有効
・permissive
SElinuxは警告を出力するが、アクセス制限は無効
・disabled
SElinux機能、アクセス制御が無効
sestatusでより詳しい情報を表示させることができます。
$ sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
また、SELinuxを無効にする場合は、/etc/selinux/config で設定します。
# 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=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
また、一時的に無効、有効にしたい場合は、以下のコマンドを実行します。
$ setenforce 1
SELinuxを有効にしている場合、 アプリケーションなどがうまく動作しないことが多いので、基本は無効にする事が多いです。
また、同様にトラブルの原因になるiptablesの無効化手順も一緒に紹介します。
その為、OS再起動後もiptablesを起動しないようにするには、chkconfigコマンドで設定します。
$ chkconfig iptables off
また、一時的に無効、有効にしたい場合は、以下のコマンドを実行します。
SELinuxを一時的に無効化
$ setenforce 0
SELinuxを有効化
$ setenforce 1
SELinuxを有効にしている場合、 アプリケーションなどがうまく動作しないことが多いので、基本は無効にする事が多いです。
また、同様にトラブルの原因になるiptablesの無効化手順も一緒に紹介します。
$ /etc/init.d/iptables stop
その為、OS再起動後もiptablesを起動しないようにするには、chkconfigコマンドで設定します。
また、iptablesを有効にしたい場合は、以下を実行します。