cap_capable(9)
π cap_capable β like, the Kernel API Manual, but make it make sense β¨
okay so bestie, welcome to cap_capable(9), straight outta the Kernel API Manual π this is the function that answers the one question every task is secretly asking: do i actually have this capability rn or am i delulu? π
πΈ NAME πΈ
cap_capable β literally just determining whether a task has a particular effective capability π no cap, that's the whole job.
π¦ SYNOPSIS π¦
int cap_capable (const struct cred *cred , struct user_namespace
*target_ns , int cap , unsigned int opts );
there she is. iconic signature, no notes. β¨
π ARGUMENTS π
credβ the credentials you're using, bestie. that's the whole vibe check right there π«Άtarget_nsβ the user namespace of the resource being accessed. like, whose house are we in πcapβ the capability you're checking for. the main character of this whole function fr fr βoptsβ a bitmask of options defined ininclude/linux/security.hβ¦ and it's unused π yeah. unused. we love a decorative parameter π
π₯ DESCRIPTION π₯
so the whole point: you determine whether the nominated task has the specified capability hanging out amongst its effective set. if it does β return 0. if it does not β return -ve (negative, not negative-vibes, though honestly both) π
NOTE WELL β οΈ and this part is so important bestie, do not skip it:cap_capablehas reverse semantics to thecapablecall and friends. like, the way that it's literally backwards?? π³
let me spell it out because this trips everyone up:
cap_capablereturns anint0when a task has a capability π- meanwhile the kernel's
capable,has_ns_capability,has_ns_capability_noaudit, andhas_capability_noauditreturn abooltrue(1) for that exact same case π
so 0 = yes and true/1 = yes. both yes. completely different numbers. it's giving chaos but that's the kernel for you π
π§ SEE ALSO π§
okay gather round, the whole friend group is here β kernel file ./security/commoncap.c cap_capable_helper(9), cap_settime(9), cap_ptrace_access_check(9), cap_ptrace_traceme(9), cap_capget(9), cap_capset(9), cap_inode_need_killpriv(9), cap_inode_killpriv(9), kuid_root_in_ns(9), rootid_from_xattr(9), cap_convert_nscap(9), get_vfs_caps_from_disk(9), cap_bprm_creds_from_file(9), cap_inode_setxattr(9), cap_inode_removexattr(9), cap_task_fix_setuid(9), cap_task_setscheduler(9), cap_task_setioprio(9), cap_task_setnice(9), cap_task_prctl(9), cap_vm_enough_memory(9), cap_mmap_addr(9) β all baddies, all worth a read π
and that's the tea π΅ this page lives under ./security, dated October 2026, and it's page cap_capable(9) of the manual β so go forth, check those effective sets, and remember: 0 means yes here. slay πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms