FreeKB - Linux Commands restorecon
Linux Commands - restorecon

The restorecon command can be used to restore a file or directory to it's default SELinux context. Files will inherit the SELinux context of the files parent directory. For example, let's say /etc/ssh has the following SELinux context.

ls -lZ /etc/ssh
drwxr-xr-x. root root     system_u:object_r:etc_t:s0

 

If foo.txt is in the /etc/ssh directory, the restorecon command will update foo.txt to have the same SELinux context as /etc/ssh.

restorecon foo.txt

 

The -v (verbose) option can be used to see the SELinux context change. In this example, the SELinux context is changed from samba_share_t to etc_t.

Note: If restorecon does not make any changes, there will be no output in the console.

~]# restorecon -v foo.txt
restorecon reset foo.txt.html context unconfined_u:object_r:samba_share_t:s0->unconfined_u:object_r:etc_t:s0

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 4e7f1 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |