SETCAP(8)

๐Ÿ“ฆ
version 2.78 ยท 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, fedora 43, fedora 44, nixpkgs unstable, ubuntu stonking

๐Ÿ’… 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