Linux "ls -Z" shows question mark for security context
Solution 1:
The meaning of the exclamation mark is only given in ls
info page, not in its man page:
'-Z'
'--context'
'--scontext'
'--lcontext'
'--format=context'Display the SELinux security context or '?' if none is found. '-Z' counts as format option and enables displaying of SELinux context. '--scontext' prints SELinux context left to the file name. '--lcontext' prints long format with SELinux context in the middle. '--context' prints permissions, user/group, context and file name (in comparison to '--lcontext', omits size, modification time and number of hardlinks).
Thus, this means that no security context was added to the file. And the fact that it still has no security context when you re-create the file indicates that the parent directory has no security context that can be inherited from.