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 -Z
command:ls -Z
The 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/config
file, enter the following command:ls -Z /etc/selinux/config
The 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 -Z
command:The output is similar to the following:
ps -Z
LABEL 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 -Z
command:id -Z
The output is similar to the following:
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023