1restorecon(8)                SELinux User Command                restorecon(8)
2
3
4

NAME

6       restorecon - restore file(s) default SELinux security contexts.
7
8

SYNOPSIS

10       restorecon  [-r|-R] [-m] [-n] [-p] [-v] [-i] [-F] [-W] [-I|-D] [-x] [-e
11       directory] pathname ...
12
13       restorecon [-f infilename] [-e directory] [-r|-R] [-m] [-n]  [-p]  [-v]
14       [-i] [-F] [-W] [-I|-D] [-x]
15
16

DESCRIPTION

18       This manual page describes the restorecon program.
19
20       This  program  is  primarily used to set the security context (extended
21       attributes) on one or more files.
22
23       It can also be run at any other time to correct inconsistent labels, to
24       add  support  for newly-installed policy or, by using the -n option, to
25       passively check whether the file contexts are all set as  specified  by
26       the active policy (default behavior).
27
28       If  a  file  object  does not have a context, restorecon will write the
29       default context to the file object's extended  attributes.  If  a  file
30       object  has  a context, restorecon will only modify the type portion of
31       the security context.  The -F option will force a  replacement  of  the
32       entire context.
33
34       If  a  file is labeled with customizable SELinux type (for list of cus‐
35       tomizable  types   see   /etc/selinux/{SELINUXTYPE}/contexts/customiza‐
36       ble_types),  restorecon  won't  reset the label unless the -F option is
37       used.
38
39       It is the same executable as setfiles but operates in a  slightly  dif‐
40       ferent manner depending on its argv[0].
41
42

OPTIONS

44       -e directory
45              exclude  a directory (repeat the option to exclude more than one
46              directory, Requires full path).
47
48       -f infilename
49              infilename contains a list of files to be processed. Use “-” for
50              stdin.
51
52       -F     Force  reset  of  context to match file_context for customizable
53              files, and the default file context, changing  the  user,  role,
54              range portion as well as the type.
55
56       -h, -? display usage information and exit.
57
58       -i     ignore files that do not exist.
59
60       -I     ignore  digest  to  force  checking of labels even if the stored
61              SHA1 digest matches the specfiles SHA1 digest. The  digest  will
62              then be updated provided there are no errors. See the NOTES sec‐
63              tion for further details.
64
65       -D     Set or update any directory SHA1 digests.  Use  this  option  to
66              enable usage of the security.sehash extended attribute.
67
68       -m     do not read /proc/mounts to obtain a list of non-seclabel mounts
69              to be excluded from relabeling checks.  Setting this  option  is
70              useful  where there is a non-seclabel fs mounted with a seclabel
71              fs mounted on a directory below this.
72
73       -n     don't change any file labels (passive check).   To  display  the
74              files whose labels would be changed, add -v.
75
76       -o outfilename
77              Deprecated - This option is no longer supported.
78
79       -p     show  progress  by  printing  the  number  of files in 1k blocks
80              unless relabeling the entire OS, that will then show the approx‐
81              imate  percentage  complete. Note that the -p and -v options are
82              mutually exclusive.
83
84       -R, -r change files and directories file  labels  recursively  (descend
85              directories).
86
87       -v     show  changes  in  file labels. Multiple -v options increase the
88              verbosity. Note that the -v and -p options are  mutually  exclu‐
89              sive.
90
91       -W     display  warnings  about  entries  that had no matching files by
92              outputting the selabel_stats(3) results.
93
94       -0     the separator for the input items is  assumed  to  be  the  null
95              character  (instead  of  the  white  space).  The quotes and the
96              backslash characters are also treated as normal characters  that
97              can form valid input.  This option finally also disables the end
98              of file string, which is treated like any other argument.   Use‐
99              ful  when  input items might contain white space, quote marks or
100              backslashes.  The -print0 option  of  GNU  find  produces  input
101              suitable for this mode.
102
103       -x     prevent restorecon from crossing file system boundaries.
104
105
106       ARGUMENTS
107              pathname ...  The pathname for the file(s) to be relabeled.
108

NOTES

110       1.  restorecon  by default does not operate recursively on directories.
111           Paths leading up the final component of the file(s) are  canonical‐
112           ized using realpath(3) before labeling.
113
114       2.  If  the  pathname  specifies  the root directory and the -vR or -vr
115           options are set and the audit system  is  running,  then  an  audit
116           event  is  automatically  logged stating that a "mass relabel" took
117           place using the message label FS_RELABEL.
118
119       3.  To improve performance when  relabeling  file  systems  recursively
120           (i.e. the -R or -r option is set), the -D option to restorecon will
121           cause it to store a SHA1 digest of the default specfiles set in  an
122           extended  attribute  named security.sehash on each directory speci‐
123           fied in pathname ...  once the relabeling has been  completed  suc‐
124           cessfully.  These  digests  will be checked should restorecon -D be
125           rerun with the same pathname parameters. See  selinux_restorecon(3)
126           for further details.
127
128           The -I option will ignore the SHA1 digest from each directory spec‐
129           ified in pathname ...  and provided the -n option is  NOT  set  and
130           recursive mode is set, files will be relabeled as required with the
131           digests then being updated provided there are no errors.
132
133

AUTHOR

135       This man page was written by Dan Walsh  <dwalsh@redhat.com>.   Some  of
136       the content of this man page was taken from the setfiles man page writ‐
137       ten by Russell Coker <russell@coker.com.au>.  The program  was  written
138       by Dan Walsh <dwalsh@redhat.com>.
139
140

SEE ALSO

142       setfiles(8),  fixfiles(8),  load_policy(8),  checkpolicy(8), customiza‐
143       ble_types(5)
144
145
146
147                                 10 June 2016                    restorecon(8)
Impressum