SELinux関係のコマンドメモ

自分の備忘録的にとりあえず覚えたコマンドを。

SELinuxの状態を確認する(sestatus)

# sestatus -v

SELinuxを有効/無効にする(setenforce)

SELinuxを無効にする
# setenforce 0

SELinuxを有効にする
# setenforce 1

ファイルにラベルを付ける(chcon/fixfiles/restorecon)

/etc/resolv.conf にsystem_u:object_r:net_conf_tのラベルを設定する(chcon)

# chcon system_u:object_r:net_conf_t /etc/resolv.conf

全てのファイルにラベルを付け直す(fixfiles)

# fixfiles relabel

/etc/resolv.conf にラベルを付け直す(restorecon)

# restorecon /etc/resolv.conf

※chcon は直接ラベルを指定するのに対して、fixfiles, restorecon は標準の設定値を使う模様。