Displaying SELinux Context Information
This task shows how to view the SELinux context information associated with different resources.
-
To display the context information that's associated with all files in a directory, use the
ls -Zcommand:ls -ZThe output is similar to the following:
-rw-------. root root system_u:object_r:admin_home_t:s0 anaconda-ks.cfg -rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 config -rw-r--r--. root root system_u:object_r:admin_home_t:s0 initial-setup-ks.cfg drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 jail -rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 team0.cfg -
You can view the context of a specific file or directory. For example, to view the context of the
/etc/selinux/configfile, enter the following command:ls -Z /etc/selinux/configThe output is similar to the following:
-rw-r--r--. root root system_u:object_r:selinux_config_t:s0 /etc/selinux/config -
To display the context information that's associated with processes, use the
ps -Zcommand:The output is similar to the following:
ps -ZLABEL PID TTY TIME CMD unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 3038 pts/0 00:00:00 su unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 3044 pts/0 00:00:00 bash unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 3322 pts/0 00:00:00 ps -
To display the context information that's associated with the current user, use the
id -Zcommand:id -ZThe output is similar to the following:
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023