LinuxCommandLibrary

errno

Display the last system call error number

TLDR

Lookup errno description by name or code

$ errno [name|code]
copy

List all errno names, codes, and descriptions
$ errno [[-l|--list]]
copy

Search for code whose description contains all of the given text
$ errno [[-s|--search]] [text]
copy

Search for code whose description contains all of the given text (all locales)
$ errno [[-S|--search-all-locales]] [text]
copy

SYNOPSIS

errno [NUMBER...]

PARAMETERS

-h, --help
    Display help message and exit

-V, --version
    Output version information and exit

DESCRIPTION

The errno command is a utility from the util-linux package that displays human-readable error messages corresponding to numeric errno values used in Linux system calls. These errno codes represent specific errors like EPERM (1: Operation not permitted) or ENOENT (2: No such file or directory).

When invoked with one or more integer arguments representing errno values (typically 1-133, depending on the system), it outputs the symbolic name and descriptive message for each. This is invaluable for debugging programs, interpreting return values from system calls via tools like strace, or quickly looking up error meanings without consulting /usr/include/asm-generic/errno-base.h or man pages.

For example, errno 2 outputs ENOENT (No such file or directory). It supports multiple arguments, printing one line per errno. The command sources messages from the system's errno definitions, ensuring accuracy across kernel versions. Primarily used by developers and sysadmins for rapid error lookup.

CAVEATS

Errno values are system-specific; some may not exist on all architectures. Accepts only valid numeric errnos (1-255 typically); invalid inputs produce no output or errors.

EXAMPLES

errno 2 13 22
Outputs:
ENOENT (No such file or directory)
EACCES (Permission denied)
EINVAL (Invalid argument)

EXIT STATUS

0 if all errnos valid, non-zero otherwise.

HISTORY

Introduced in util-linux package around version 2.23 (2013). Developed by Karel Zak as part of coreutils enhancements for better system diagnostics.

SEE ALSO

perror(1), strace(1), err(3)

Copied to clipboard