Display the security context associated with files or directories under SELinux kernel
Q. I’m using CentOS Linux server 5 with SELinux enabled kernel. How do I display the security context associated with files or directories under SELinux kernel? Basically I’d like to know which SELinux security context applies to some files or directories.
A.. To get more information about SELinux security context applied to files and directory you need to use patched ls command. CentOS comes with modified (patched) ls command. Following are the SELinux ls command options:
- --lcontext : Display security context. Enable -l. Lines will probably be too wide for most displays.
- -Z or --context : Display security context so it fits on most displays. Displays only mode, user, group, security context and file name.
- --scontext : Display only security context and file name.
Type ls -Z command you will see the SELinux applied security context:
# ls -Z /var
# ls -Z /home
# ls --lcontext /etc
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- How to Linux re apply or restore SELinux security labels context
- Disable SELinux for only Apache / httpd in Linux
- Turn off: disable selinux (Security-Enhanced Linux)
- Apache Address already in use: make_sock: could not bind to port 80 or 443 error and solution
- Find the file permission without using ls -l command
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!




Recent Comments
Today ~ 3 Comments
Today ~ 5 Comments
Today ~ 1 Comment
Yesterday ~ 1 Comment
Yesterday ~ 2 Comments