errno
Display the last system call error number
TLDR
Lookup errno description by name or code
List all errno names, codes, and descriptions
Search for code whose description contains all of the given text
Search for code whose description contains all of the given text (all locales)
SYNOPSIS
errno [number]
PARAMETERS
number
Optional. A numeric error code. If provided, errno
will attempt to find and print the corresponding error name.
If not provided, errno
will print a list of errno names with values.
DESCRIPTION
The errno
command in Linux is a simple utility that displays the symbolic name of a given error number, as defined in the system's error code header files (typically errno.h
). This is helpful for debugging and understanding the meaning of error codes returned by system calls or library functions. The command essentially acts as a lookup table, mapping numeric error values to their corresponding symbolic names, such as EACCES
(Permission denied) or ENOENT
(No such file or directory). It simplifies error analysis by translating raw numeric codes into human-readable, meaningful names. It's a useful tool for developers and system administrators when troubleshooting programs and identifying the root cause of errors.
When invoked without arguments, errno
will print a list of errno names with values. errno {number}
will translate that number to the errno name.
CAVEATS
The exact set of error codes and their meanings can vary slightly between different Linux distributions and kernel versions. The values are dependent on the system header files.
EXAMPLE USAGE
To find the error name for error code 2:errno 2
This might output something like: ENOENT
USE IN SCRIPTS
The command is most often used in interactive debugging, but can also be used in scripts to translate a return code to a text representation.
HISTORY
The errno
command has been a standard utility in Unix-like operating systems for a long time. It serves to access the meaning of the global variable errno
as defined in the C standard library. It's primary purpose is to translate error codes generated by the system into human understandable names.
SEE ALSO
strerror(3), perror(3)