selinux 20241127

SELinux Modes

selinux 20241127 1

selinux 20241127 2 selinux 20241127 3 selinux 20241127 4

SELinux Context

ls -lZ
ls -lZd
 
 
man semanage-fcontext
semanage fcontext -a
semanage fcontext -a -e
semnaage fcontext -m
semanage fcontext -l -C
 
restorecon -Rv <directory> | touch /.autorelebel

difference_between_selinux_fcontext_commands

selinux 20241127 8

selinux 20241127 9

selinux 20241127 10

  • use ls -lZ to get the context also

selinux 20241127 11

selinux 20241127 12

selinux 20241127 13

selinux 20241127 14

selinux 20241127 15

systemctl restart httpd

selinux 20241127 16

SELinux Port

man semanage-port
 
semanage port -l
 
semanage port -a -t http_port_t -p tcp 81
semanage port -a -t ssh_port_t -p tcp 8991
 
ss -tunap

selinux 20241127 7

semanage port -a -t http_port_t -p tcp 82

SELinux Booleans

selinux 20241127 5

semanage boolean -l
semanage boolean -l | grep httpd
setsebool -P <boolean> [on|off]
semanage boolean -l -C
getsebool -a
getsebool -a | grep httpd

selinux 20241127 6

# -P for making it persistent across boots
setsebool -P httpd_enable_homedirs on