0

why does ls -Z returns files names with question marks next to them? And what does this command do?

muru
  • 207,228
Ulukai
  • 425
  • 1
  • 6
  • 14

2 Answers2

4

The manpage for ls says:

-Z, --context
       print any SELinux security context of each file

since you are not running SELinux the ? appears in front of the file as it cannot read that part of it since it does not exist.

More information about SELinux can be found here.

Terrance
  • 43,712
0

The accepted answer feels misleading. One can imply that ? is displayed whenever /etc/selinux/config SELINUX is set to disabled.

I have it set to disabled, but running ls -Z shows ? for some files while for others does return their security contexts. It is true that ? will be displayed when selinux is not installed/in use, but it is not the complete answer.

This article says ? means the absence of a security label for that file/object.

To add one, use chchon command.

Veverke
  • 103