SELinux cheatsheet
Published on Jan 19, 2019 by Sachin.
Display selinux context
1: ls -lZ /etc/httpd/conf/httpd.conf 2: 3: # Output 4: -rw-r--r--. 1 root root system_u:object_r:httpd_config_t:s0 11753 Apr 17 14:23 /etc/httpd/conf/httpd.conf
system_u
: Userobject_r
: Rolehttpd_config_t
: Types0
: Order/Range
Change selinux context
1: # Syntax 2: chcon <context> <file> 3: 4: # Example 5: chcon system_u:object_r:httpd_config_t:s0 /etc/httpd/conf/httpd.conf
or referencing other file
chcon --reference=ssl.conf httpd.conf
Change user
chcon -u system_u httpd.conf
Change role
chcon -r object_r httpd.conf
Change type
chcon -t httpd_config_t httpd.conf
Change Order/Range/Level
chcon -l s0 httpd.conf