| 1 |
.TH SETCAP 8 "2025-03-19" |
| 2 |
.SH NAME |
| 3 |
setcap \- set file capabilities |
| 4 |
.SH SYNOPSIS |
| 5 |
\fBsetcap\fP [\-q] [\-n <rootuid>] [\-v] {\fIcapabilities|\-|\-r} filename\fP [ ... \fIcapabilitiesN\fP \fIfileN\fP ] |
| 6 |
.SH DESCRIPTION |
| 7 |
In the absence of the |
| 8 |
.B \-v |
| 9 |
(verify) option |
| 10 |
.B setcap |
| 11 |
sets the capabilities of each specified |
| 12 |
.I filename |
| 13 |
to the |
| 14 |
.I capabilities |
| 15 |
specified. The optional |
| 16 |
.B \-n <rootuid> |
| 17 |
argument can be used to set the file capability for use only in a |
| 18 |
user namespace with this root user ID owner. The |
| 19 |
.B \-v |
| 20 |
option is used to verify that the specified capabilities are currently |
| 21 |
associated with the file. If \-v and \-n are supplied, the |
| 22 |
.B \-n <rootuid> |
| 23 |
argument is also verified. |
| 24 |
.PP |
| 25 |
The |
| 26 |
.I capabilities |
| 27 |
Set are specified in the form described in |
| 28 |
.BR cap_text_formats (7). |
| 29 |
.PP |
| 30 |
The special capability string, |
| 31 |
.BR '\-' , |
| 32 |
can be used to indicate that capabilities are read from the standard |
| 33 |
input. In such cases, the capability set is terminated with a blank |
| 34 |
line. |
| 35 |
.PP |
| 36 |
The special capability string, |
| 37 |
.BR '\-r' , |
| 38 |
is used to remove a capability set from a file. Note, setting an empty |
| 39 |
capability set is |
| 40 |
.B not the same |
| 41 |
as removing it. An empty set can be used to guarantee a file is not |
| 42 |
executed with privilege in spite of the fact that the prevailing |
| 43 |
ambient+inheritable sets would otherwise bestow capabilities on |
| 44 |
executed binaries. |
| 45 |
.PP |
| 46 |
The |
| 47 |
.BR '\-f' , |
| 48 |
is used to force completion even when it is in some way considered |
| 49 |
an invalid operation. This can affect |
| 50 |
.B '\-r' |
| 51 |
and setting file capabilities the kernel will not be able to make |
| 52 |
sense of. |
| 53 |
.PP |
| 54 |
The |
| 55 |
.B \-q |
| 56 |
flag is used to make the program less verbose in its output. |
| 57 |
.SH "EXIT CODE" |
| 58 |
The |
| 59 |
.B setcap |
| 60 |
program will exit with a 0 exit code if successful. On failure, the |
| 61 |
exit code is 1. |
| 62 |
.SH "REPORTING BUGS" |
| 63 |
Please report bugs via: |
| 64 |
.TP |
| 65 |
https://bugzilla.kernel.org/buglist.cgi?component=libcap&list_id=1090757 |
| 66 |
.SH "SEE ALSO" |
| 67 |
.BR capsh (1), |
| 68 |
.BR cap_from_text (3), |
| 69 |
.BR cap_get_file (3), |
| 70 |
.BR cap_text_formats (7), |
| 71 |
.BR capabilities (7), |
| 72 |
.BR user_namespaces (7), |
| 73 |
.BR captree (8), |
| 74 |
.BR getcap (8) |
| 75 |
and |
| 76 |
.BR getpcaps (8). |