1restorecon(8) SELinux User Command restorecon(8)
2
3
4
6 restorecon - restore file(s) default SELinux security contexts.
7
8
10 restorecon [-r|-R] [-m] [-n] [-p] [-v] [-i] [-F] [-W] [-I|-D] [-e
11 directory] pathname ...
12
13 restorecon [-f infilename] [-e directory] [-r|-R] [-m] [-n] [-p] [-v]
14 [-i] [-F] [-W] [-I|-D]
15
16
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
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
104 ARGUMENTS
105 pathname ... The pathname for the file(s) to be relabeled.
106
108 1. restorecon does not follow symbolic links and by default it does
109 not operate recursively on directories.
110
111 2. If the pathname specifies the root directory and the -vR or -vr
112 options are set and the audit system is running, then an audit
113 event is automatically logged stating that a "mass relabel" took
114 place using the message label FS_RELABEL.
115
116 3. To improve performance when relabeling file systems recursively
117 (i.e. the -R or -r option is set), the -D option to restorecon will
118 cause it to store a SHA1 digest of the default specfiles set in an
119 extended attribute named security.sehash on each directory speci‐
120 fied in pathname ... once the relabeling has been completed suc‐
121 cessfully. These digests will be checked should restorecon -D be
122 rerun with the same pathname parameters. See selinux_restorecon(3)
123 for further details.
124
125 The -I option will ignore the SHA1 digest from each directory spec‐
126 ified in pathname ... and provided the -n option is NOT set and
127 recursive mode is set, files will be relabeled as required with the
128 digests then being updated provided there are no errors.
129
130
132 This man page was written by Dan Walsh <dwalsh@redhat.com>. Some of
133 the content of this man page was taken from the setfiles man page writ‐
134 ten by Russell Coker <russell@coker.com.au>. The program was written
135 by Dan Walsh <dwalsh@redhat.com>.
136
137
139 setfiles(8), fixfiles(8), load_policy(8), checkpolicy(8), customiza‐
140 ble_types(5)
141
142
143
144 10 June 2016 restorecon(8)