How to know what the ‘errno’ means in Linux?

LinuxOperating SystemOpen Source

Errno is a value that you get when the command you run returns the value of the call indicating an error. There is a header file that defines the integer variable errno, which is set by the system calls and some library function in the event of an error to let the developer know what’s wrong.

In simple terms, the “errnos” are symptoms of operating system errors. Generally produced by failed operating system calls.

In UNIX, the errnos are defined in upper case letters.

Example

EPERM
ENOENT
ESRCH
EINTR
EIO
ENXIO

In the above examples, some formatted errnos are mentioned that have different values and meaning attached to them.

While ‘errno’ is present on most Linux based systems, you can still download the tool with the help of the commands shown below.

For Ubuntu/Fedora

sudo apt-get install errno

For CentOS

yum install errno

Once we have the errno tool installed we can list out all the errno symbols and their meanings attached with them with the help of the command shown below −

errno -l

Output

1 EPERM Operation not permitted
2 ENOENT No such file or directory
3 ESRCH No such process
4 EINTR Interrupted system call
5 EIO Input/output error
6 ENXIO No such device or address
7 E2BIG Argument list too long
8 ENOEXEC Exec format error
9 EBADF Bad file descriptor
10 ECHILD No child processes

It should be noted that there are more than 130 entries in the above output, I just listed out the top 10.

As we can see we have the description attached to each errno and with the help of the above output we can easily determine what the ‘errno’ actually means.

Another simpler way is to simply print the numbered errno, instead of printing the entire table.

Command

errno 2

Output

No such file or directory
raja
Published on 30-Jul-2021 08:54:44
Advertisements