CentOS_Stream8

CentOS Stream 8 SELinux 状態確認 設定の変更

SELinux(Security-Enhanced Linux)は、システムのセキュリティを強固にすることができる機能です。

SELinuxの状態

SElinuxは以下のような状態(ステータス)があります。

EnforcingSELinuxは有効で、アクセス制限も有効
PermissiveSELinuxは有効だが、アクセス制御は行われず警告を出力
DisabledSELinuxは無効

SELinuxの状態を確認を行うには getenforce を実行します。

[root@centos-stream8 ~]# getenforce
Enforcing
[root@centos-stream8 ~]#

SELinux 設定の変更

SELinuxを変更するには、以下のように設定します。

一時的に変更する場合

一時的(システム再起動するまで)に変更する場合は、 setenforce コマンドを実行します。

#一時的に無効化
[root@centos-stream8 ~]# setenforce 0
[root@centos-stream8 ~]# getenforce
Permissive
#一時的に有効化
[root@centos-stream8 ~]# setenforce 1
[root@centos-stream8 ~]# getenforce
Enforcing
[root@centos-stream8 ~]#

恒久的に変更する方法

恒久的にSELinuxの状態を変更する場合には /etc/selinux/config ファイルのSELINUXの行を設定したいステータスに変更します。
下記の例は無効設定である、「disabled」に変更を行っています。

[root@centos-stream8 ~]# vi /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=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


[root@centos-stream8 ~]#

設定を反映するのに reboot コマンドで再起動を実施します。

[root@centos-stream8 ~]# reboot

 / 省略 再起動 /

[root@centos-stream8 ~]# getenforce
Disabled
[root@centos-stream8 ~]#

CentOS Stream8 記事一覧

-CentOS_Stream8