KEYCTL_UNLINK(2const)

okay so listen. this is a manual page from KEYCTL_UNLINK(2const) and it's literally about yanking a key out of a keyring. nothing more, nothing less. iconic behavior, honestly. let's get into it πŸ’–


✨ NAME ✨

KEYCTL_UNLINK β€” unlink a key from a keyring

like. the name is the plot. it unlinks. a key. from a keyring. we ate πŸ“


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc) β€” the classic, the moment, the blueprint 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <linux/keyctl.h>  /* Definition of KEY* constants */
#include <sys/syscall.h>   /* Definition of SYS_* constants */
#include <unistd.h>

long syscall(SYS_keyctl, KEYCTL_UNLINK, key_serial_t key,
             key_serial_t keyring);

not me showing you the whole invocation. copy it exactly bestie, character for character, do NOT freestyle this 😭


🌸 DESCRIPTION 🌸

So the whole vibe here? Unlink a key from a keyring. Periodt. That's the assignment.

Here's the tea tho, because there's two IDs and you have to keep them straight:

  • The ID of the key that's getting unlinked? That's in key.
  • The ID of the keyring you're unlinking it from? That's in keyring.

And listen β€” if the key isn't currently linked into that keyring at all? an error results. You can't unlink something that was never linked, and no amount of manifesting changes that πŸ™ˆ

Also, and this is the part people skip and then get confused: the caller must have write permission on the keyring from which the key is being removed. So it's not just about the key, bestie. It's about the keyring you're messing with. vibe check your permissions first πŸ’œ

And now the dramatic one: if the last link to a key is removed, then that key will be scheduled for destruction. 😭 like okay!!! that's main character energy with real consequences. that key is getting scheduled. for. destruction. no cap.


⭐ RETURN VALUE ⭐

  • On success, 0 is returned. slay ✨
  • On error, -1 is returned, and errno is set to indicate the error. it's giving "check your errno, that's where the gossip lives" πŸ’€

πŸ’€ ERRORS πŸ’€

  • ENOENT β€” the key you're trying to unlink isn't linked to the keyring. i literally just said this. it was never there. why were you trying. 😭

πŸ¦‹ VERSIONS πŸ¦‹

Good news for the girlies who don't want to raw-dog the syscall: a wrapper is provided in the libkeyutils library β€” keyctl_unlink(3). so convenient. so thoughtful. obsessed πŸŽ€


🌈 STANDARDS 🌈

Linux. that's it, that's the standard. πŸ’…


πŸ‘‘ HISTORY πŸ‘‘

Linux 2.6.10. ancient. vintage. still serving. ⭐


πŸ”₯ SEE ALSO πŸ”₯


fr fr, the one thing to remember: write permission on the keyring, and if it's the last link, that key is getting scheduled for destruction. that's not a drill bestie πŸ’–

and that's the whole page, bestie!! this one came from Linux man-pages 6.20, dated 2026-02-08, and it was KEYCTL_UNLINK(2const) all along 🫢 go forth and unlink responsibly ✨🌺

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms