SETCAP(8)
๐ setcap(8) โ bestie edition โจ
okay so this is setcap, from the System Manager's Manual, and it is literally the tool that gives a file its whole capability situation. it's giving "i decide what powers you get" and honestly? iconic. ๐
๐ธ NAME ๐ธ
setcap โ set file capabilities ๐
โจ SYNOPSIS โจ
setcap [-q] [-n <rootuid>] [-v] {capabilities|-|-r} filename [ ...
capabilitiesN fileN ]
๐ฆ DESCRIPTION ๐ฆ
so like, if you do not pass the -v (verify) option, setcap takes each filename you listed and sets its capabilities to whatever capabilities you told it to. simple. slay.
the optional -n <rootuid> argument? you use it to set the file capability so it only applies inside a user namespace whose root user ID owner is that <rootuid>. very specific, very demure.
the -v option is for verifying โ it checks that the capabilities you named are the ones currently associated with the file. and if you hand over both -v and -n, then the -n <rootuid> argument gets verified too. double check, no cap. โ
the capabilities you're setting get written in the form described over in cap_text_formats(7).
now, the special capability string '-' โ that one means "read the capabilities from standard input". and when you do that, the capability set ends with a blank line. periodt.
the special capability string '-r' โ that's the one that removes a capability set from a file. ๐จ and listen, this part matters: setting an empty capability set is not the same thing as removing it. an empty set can be used to guarantee that a file is not executed with privilege, even though the prevailing ambient+inheritable sets would otherwise bestow capabilities on executed binaries.
the '-f', is used to force completion even when it's in some way considered an invalid operation. this can affect '-r' and setting file capabilities the kernel will not be able to make sense of. ๐ so like, you're on your own with that one, bestie.
the -q flag is used to make the program less verbose in its output. quieter. mysterious. main character energy. ๐คซ
๐ EXIT CODE ๐
the setcap program will exit with a 0 exit code if successful. on failure, the exit code is 1. that's it, that's the whole vibe check.
๐ญ REPORTING BUGS ๐ญ
please report bugs via:
https://bugzilla.kernel.org/buglist.cgi?component=libcap&list_id=1090757
like actually report them, don't just complain in the group chat ๐
๐ SEE ALSO ๐
capsh(1), cap_from_text(3), cap_get_file(3), cap_text_formats(7), capabilities(7), user_namespaces(7), captree(8), getcap(8) and getpcaps(8).
go read those too, iykyk ๐ซถ
and that's the whole page, bestie โ this one's from the System Manager's Manual, dated 2025-03-19, and it's SETCAP(8) forever and always. drink water, read your manpages, and don't set capabilities you can't handle ๐โจ๐
๐ฆ where this page comes from
- alpine 3.22: libcap-doc 2.78-r0 ยท BSD-3-Clause OR GPL-2.0-only
- alpine 3.23: libcap-doc 2.78-r0 ยท BSD-3-Clause OR GPL-2.0-only
- alpine 3.24: libcap-doc 2.78-r0 ยท BSD-3-Clause OR GPL-2.0-only
- arch rolling: libcap 2.78-1 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 43: libcap 2.76-3.fc43 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 43: libcap 2.76-3.fc43 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 43: libcap 2.76-4.fc43 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 43: libcap 2.76-4.fc43 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 44: libcap 2.77-2.fc44 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 44: libcap 2.77-2.fc44 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 44: libcap 2.78-1.fc44 ยท BSD-3-Clause OR GPL-2.0-only
- fedora 44: libcap 2.78-1.fc44 ยท BSD-3-Clause OR GPL-2.0-only
- nixpkgs unstable: libcap 2.78
- ubuntu stonking: libcap2-bin 1:2.78-1ubuntu1 ยท BSD-3-Clause OR GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms