0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SElinux無効化・コンテキストの削除

Last updated at Posted at 2025-10-11

方法1: 設定ファイル変更による無効化

1. 現在の設定確認

grep SELINUX /etc/selinux/config

2. 設定ファイル変更

sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

3. 変更内容確認

grep SELINUX /etc/selinux/config

期待値: SELINUX=disabled

4. システム再起動

reboot

5. 無効化確認

getenforce

期待値: Disabled


方法2: カーネルパラメータによる無効化

1. 現在の状態確認

getenforce

2. カーネルパラメータ設定

grubby --update-kernel ALL --args selinux=0

3. システム再起動

reboot

4. 無効化確認

getenforce

期待値: Disabled


SELinuxコンテキストの削除

SELinux無効化後、ファイルシステムに残存するSELinuxコンテキストを削除する手順です。

1. コンテキスト状態確認

[root@NFS ~]# ls -lZ /var/www/html/
total 4
-rw-r--r--. 1 root root unconfined_u:object_r:httpd_sys_content_t:s0 29 Mar 2 17:48 index.HTML
[root@NFS ~]# attr -l /var/www/html/
Attribute "selinux" has a 41 byte value for /var/www/html/

2. 特定ディレクトリのコンテキスト削除

setfattr -x security.selinux /var/www/html/

3. 再帰的にコンテキスト削除

find /path/to/directory -exec setfattr -x security.selinux {} \;

補足情報

SELinuxモード一覧

  • Enforcing: SELinuxポリシーを強制適用
  • Permissive: 違反をログ記録するが許可
  • Disabled: SELinux無効

一時的な無効化

永続的な無効化ではなく一時的な変更の場合:

setenforce 0  # Permissiveモードに変更
setenforce 1  # Enforcingモードに変更
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?