KEYCTL_CLEAR(2const)
β¨ KEYCTL_CLEAR β¨
okay bestie, so you know how a keyring is just... a little bag of keys? π this is the syscall that β¨empties the whole bagβ¨. it's KEYCTL_CLEAR, and yes it lives in the <linux/keyctl.h> cinematic universe. want to know which libc it's repping? Standard C library (libc, -lc). iconic, as always π
πΈ SYNOPSIS πΈ
like, here's the whole vibe, copy-paste ready:
#include <linux/keyctl.h> /* Definition of KEY* constants */
#include <sys/syscall.h> /* Definition of SYS_* constants */
#include <unistd.h>
long syscall(SYS_keyctl, KEYCTL_CLEAR, key_serial_t key);
no cap, that's literally it π«Ά
π DESCRIPTION π
so what does it actually do? it clears the contents of a keyring β and by "clears the contents" we mean it unlinks all keys from that keyring. every single one. gone. not the keys themselves being deleted, bestie, just unlinked from this ring. the way that's an important distinction π
the ID of the key β which must be of keyring type, don't try to be cute with something else β is passed in key. that's the whole argument, she's simple like that.
β οΈ and here's the part where you lock in: the caller must have write permission on the keyring. no write permission, no clear. periodt.
π¦ RETURN VALUE π¦
- success β
0is returned. slay β¨ - error β
-1is returned, anderrnois set to tell you what went wrong. read it, she's trying to communicate π
π VERSIONS π
good news!! there's a wrapper so you don't have to do the raw syscall dance by yourself β it's provided in the libkeyutils library: keyctl_clear(3). use it, it's giving convenience π
π STANDARDS π
Linux. that's it, that's the standard. iykyk π§
π HISTORY π
Linux 2.6.10. ancient. vintage. a classic π°οΈ
π SEE ALSO π
the cousins, the besties, the group chat:
and that's the tea, bestie π
this lil page came straight out of Linux man-pages 6.20, dated 2026-02-08, filed under KEYCTL_CLEAR(2const). go clear a keyring responsibly, mwah π
π¦ 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
- Copyright 2016, Michael Kerrisk <mtk.manpages@gmail.com>
- Copyright 2016, Eugene Syromyatnikov <evgsyr@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms