Skip to Content
Mastering Linux Security and Hardening
book

Mastering Linux Security and Hardening

by Donald A. Tevault
January 2018
Intermediate to advanced
376 pages
8h 45m
English
Packt Publishing
Content preview from Mastering Linux Security and Hardening

Using restorecon

Using restorecon is easy. Just type restorecon, followed by the name of the file that you need to change. Once again, I've changed the context of the index.html file back to the home directory type. This time though, I'm using restorecon to set the correct type:

[donnie@localhost html]$ ls -Z-rw-rw-r--. donnie donnie unconfined_u:object_r:user_home_t:s0 index.html[donnie@localhost html]$ sudo restorecon index.html[donnie@localhost html]$ ls -Z-rw-rw-r--. donnie donnie unconfined_u:object_r:httpd_sys_content_t:s0 index.html[donnie@localhost html]$

And, that's all there is to it.

You can also use chcon and restorecon to change the context of an entire directory and its contents. For either one, just use the -R option. For example: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Security and Hardening, The Practical Security Guide

Linux Security and Hardening, The Practical Security Guide

Jason Cannon
Mastering Linux Administration

Mastering Linux Administration

Alexandru Calcatinge, Julian Balog

Publisher Resources

ISBN: 9781788620307Other