0

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

muru
  • 193,181
  • 53
  • 473
  • 722
Ulukai
  • 385
  • 3
  • 13
  • 2
    -1 for [a continued inability to read manpages](http://askubuntu.com/q/685620/158442). – muru Oct 15 '15 at 22:12

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
  • 39,774
  • 7
  • 116
  • 176
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
  • 5