How to Linux re apply or restore SELinux security labels context
Q. How do I set back the file security contexts to specific files or directories under SElinux enabled kernel? I have restored the /wwwdata/domain1, domain2 directories but my security labels are incorrect.
A. If files or directories restored from backup or compied from other source over network/medium you need to restore back SELinux security labels.
Use restorecon command to set file security contexts. This command is primarily used to set the security context (extended attributes) on one or more files. It can be run at any time to correct errors, to add support for new policy, or with the -n option it can just check whether the file contexts are all as you expect.
Type the following command to re-label all the files under the correct security context:
# restorecon -Rv /wwwdata
Where,
- -R: Change files and directories file labels recursively
- -v: Show changes in file labels.
Read man page of restorecon for more information.
E-mail this to a friend
Printable version
Related Other Helpful FAQs:
- Display the security context associated with files or directories under SELinux kernel
- 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
- CentOS Linux apply package updates
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
Yesterday ~ 77 Comments
Yesterday ~ 2 Comments
10/10/2008 05:34 pm (2 days ago) ~ 1 Comment
10/10/2008 05:21 pm (2 days ago) ~ 8 Comments
10/10/2008 12:39 pm (2 days ago) ~ 1 Comment