ls -Z Option Yields ‘?’ in Output

lsselinux

I was reading the book "Linux Bible", chapter 24 to understand SELinux. In the book the author says that using $ ls -Z my_stuff in the command should display the DAC controls and RBAC controls over the file. Something like this:

$ ls -Z my_stuff
-rw-rw-r--. johndoe johndoe unconfined_u:object_r:user_home_t:s0 my_stuff

But when I tried it out in my terminal, it displays a "?" in front of all listed files/directories:

base ❯ ls -Z vim_cheatsheet.png 
? vim_cheatsheet.png

(The "?" is showing up for any file I try to view with ls -Z)

Checked the man pages of ls and that didn't give much information on this option.
Any idea what the "?" means here?

Best Answer

? means that no SELinux context was found:

Display the SELinux security context or ‘?’ if none is found.

SELinux isn’t installed or enabled by default everywhere; for example, Fedora and RHEL install and enable it by default, but Debian and Ubuntu don’t.

Related Question