---
name: "getseuserbyname"
section: "3"
platform: "linux"
package: "libselinux1-dev"
version: "3.8.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/getseuserbyname"
---

# getseuserbyname(3)

get SELinux username and level for a given Linux username

## NAME

getseuserbyname - get SELinux username and level for a given Linux username

## SYNOPSIS

**#include \<selinux/selinux.h\>**

**int getseuserbyname(const char \****linuxuser***, char \*\****selinuxuser***, char \*\****level***);**

## DESCRIPTION

**getseuserbyname**() retrieves the SELinux username and security level associated with a given Linux username.  The SELinux username and security level can then be passed to other libselinux functions such as [**get\_ordered\_context\_list\_with\_level**(3)](/get_ordered_context_list_with_level/3.md) and [**get\_default\_context\_with\_level**(3)](/get_default_context_with_level/3.md).

The returned SELinux username and level should be freed by the caller using free.

## RETURN VALUE

On success, 0 is returned. On failure, -1 is returned and *errno* is set appropriately.

The errors documented for the [**stat**(2)](/stat/2.md) system call are also applicable here.

## SEE ALSO

[**selinux**(8)](/selinux/8.md)
