Display the security context associated with files or directories under SELinux kernel

ww‮tual.w‬turi.com
Display the security context associated with files or directories under SELinux kernel

To display the security context associated with files or directories under an SELinux kernel, you can use the ls -Z command.

ls -Z

This will list the files and directories in the current directory, along with their security contexts.

To display the security context for a specific file or directory, use the ls -Z command followed by the name of the file or directory.

For example, to display the security context for the /etc/shadow file:

ls -Z /etc/shadow

The output will display the security context for the file, in the format user:role:type:level.

You can also use the stat command with the --format option to display the security context of a file or directory:

stat --format '%C' FILE_NAME

Replace FILE_NAME with the name of the file or directory that you want to display the security context for.

For example, to display the security context for the /etc/shadow file:

stat --format '%C' /etc/shadow
Created Time:2017-10-28 14:02:28  Author:lautturi