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] [-T nthreads]
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 de‐
29       fault context to the file object's extended attributes. If a  file  ob‐
30       ject has a context, restorecon will only modify the type portion of the
31       security context.  The -F option will force a replacement of the entire
32       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              SHA256 digest matches the specfiles SHA256  digest.  The  digest
62              will then be updated provided there are no errors. See the NOTES
63              section for further details.
64
65       -D     Set or update any directory SHA256 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 un‐
80              less relabeling the entire OS, that will then show the  approxi‐
81              mate  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       -T nthreads
106              use up to nthreads threads.  Specify 0 to create as many threads
107              as there are available CPU cores; 1 to use only a single  thread
108              (default);  or  any  positive  number to use the given number of
109              threads (if possible).
110
111
112       ARGUMENTS
113              pathname ...  The pathname for the file(s) to be relabeled.
114

NOTES

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

EXAMPLE

141       Fix labeling of /var/www/ including all sub-directories and list all context changes
142       # restorecon -rv /var/www/
143       List mislabeled files in user home directory and what the correct label should be
144       # restorecon -nvr ~
145       Fix labeling of files listed in file_list file, ignoring any that do not exist
146       # restorecon -vif file_list
147
148

AUTHOR

150       This  man  page  was written by Dan Walsh <dwalsh@redhat.com>.  Some of
151       the content of this man page was taken from the setfiles man page writ‐
152       ten  by  Russell Coker <russell@coker.com.au>.  The program was written
153       by Dan Walsh <dwalsh@redhat.com>.
154
155

SEE ALSO

157       setfiles(8), fixfiles(8),  load_policy(8),  checkpolicy(8),  customiza‐
158       ble_types(5)
159
160
161
162                                 10 June 2016                    restorecon(8)
Impressum