---
name: "libudev"
section: "3"
platform: "linux"
package: "systemd-libs"
version: "262.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libudev"
---

# libudev(3)

API for enumerating and introspecting local devices

## NAME

libudev - API for enumerating and introspecting local devices

## SYNOPSIS

```
#include <libudev.h>
```

**pkg-config --cflags --libs libudev**

## DESCRIPTION

libudev.h provides an API to introspect and enumerate devices on the local system. This library is supported, but should not be used in new projects. Please see [**sd-device**(3)](/sd-device/3.md) for an equivalent replacement with a more modern API.

All functions require a libudev context to operate. This context can be created via [**udev\_new**(3)](/udev_new/3.md). It is used to track library state and link objects together. No global state is used by libudev, everything is always linked to a udev context.

All functions listed here are thread-agnostic and only a single thread may operate on a given object at any given time. Different threads may access the same object at different times. Multiple independent objects may be used from different threads in parallel.

The code described here uses [**getenv**(3)](/getenv/3.md), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not call [**setenv**(3)](/setenv/3.md) from a parallel thread. It is recommended to only do calls to **setenv()** from an early phase of the program when no other threads have been started.

To introspect a local device on a system, a udev device object can be created via [**udev\_device\_new\_from\_syspath**(3)](/udev_device_new_from_syspath/3.md) and friends. The device object allows one to query current state, read and write attributes and lookup properties of the device in question.

To enumerate local devices on the system, an enumeration object can be created via [**udev\_enumerate\_new**(3)](/udev_enumerate_new/3.md).

To monitor the local system for hotplugged or unplugged devices, a monitor can be created via [**udev\_monitor\_new\_from\_netlink**(3)](/udev_monitor_new_from_netlink/3.md).

Whenever libudev returns a list of objects, the [**udev\_list\_entry**(3)](/udev_list_entry/3.md) API should be used to iterate, access and modify those lists.

Furthermore, libudev also exports legacy APIs that should not be used by new software (and as such are not documented as part of this manual). This includes the hardware database known as **udev\_hwdb** (please use the new [**sd-hwdb**(3)](/sd-hwdb/3.md) API instead) and the **udev\_queue** object to query the udev daemon (which should not be used by new software at all).

## SEE ALSO

[**udev\_new**(3)](/udev_new/3.md), [**udev\_device\_new\_from\_syspath**(3)](/udev_device_new_from_syspath/3.md), [**udev\_enumerate\_new**(3)](/udev_enumerate_new/3.md), [**udev\_monitor\_new\_from\_netlink**(3)](/udev_monitor_new_from_netlink/3.md), [**udev\_list\_entry**(3)](/udev_list_entry/3.md), [**systemd**(1)](/systemd/1.md), [**sd-device**(3)](/sd-device/3.md), [**sd-hwdb**(3)](/sd-hwdb/3.md), [**pkg-config**(1)](/pkg-config/1.md)
