---
name: "KEYCTL_CHOWN"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/KEYCTL_CHOWN"
---

# KEYCTL\_CHOWN(2const)

change the ownership of a key

## NAME

KEYCTL\_CHOWN - change the ownership of a key

## LIBRARY

Standard C library (*libc*, *-lc*)

## 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\_CHOWN, key\_serial\_t** *key***,**              **uid\_t** *uid***, gid\_t** *gid***);**

## DESCRIPTION

Change the ownership (user and group ID) of a key.

*key* contains the key ID. *uid* contains the new user ID (or -1 in case the user ID shouldn't be changed). *gid* contains the new group ID (or -1 in case the group ID shouldn't be changed).

The key must grant the caller *setattr* permission.

For the UID to be changed, or for the GID to be changed to a group the caller is not a member of, the caller must have the **CAP\_SYS\_ADMIN** capability (see [**capabilities**(7)](/capabilities/7.md)).

If the UID is to be changed, the new user must have sufficient quota to accept the key. The quota deduction will be removed from the old user to the new user should the UID be changed.

## RETURN VALUE

On success, 0 is returned.

On error, -1 is returned, and *errno* is set to indicate the error.

## VERSIONS

A wrapper is provided in the *libkeyutils* library: [**keyctl\_chown**(3)](/keyctl_chown/3.md).

## STANDARDS

Linux.

## HISTORY

Linux 2.6.10.

## SEE ALSO

[**keyctl**(2)](/keyctl/2.md), [**keyctl\_chown**(3)](/keyctl_chown/3.md)
