Linux Error Codes

Linux error codes are those codes that are displayed if an error occurs in the system while working or using a program. The errors can be recognized with the help of error codes. The error codes assist us in recognizing the source of error.

If we are working on a Linux system, it is obvious that we may encounter errors. Some errors can be minor and may not lead to interruption of the program. But there can be some errors that can cause a system or program to stop responding. These errors can lead to loss of data or may prevent the program from completing. Mostly errors are displayed in the form of codes or messages.

In this section, we will see errors in C programming and a list of possible errors in the Linux system.

Linux Errors in C programming

A skilled programmer should know how to deal with the errors. C programming language does not provide direct support for error handling. We have to detect the source of the error and deal with it. In C language, the return values display the failure or success. If a function in the C program fails, we must handle the error accordingly; otherwise it records the errors last in a log file.

While executing the C programs, we might notice some error numbers such as "Error no is: 17". Here, the error no 17 means the file already exists. Every error number has some meaning.

The C language supports a variable 'errorno.' By using this error number variable, we can use some error handling functions to handle it properly.

To use the external variable error number, we have to include a header file 'errno.h.' The <error.h> header file is used to define the 'errno' variable. The errno variable is set by the system calls and library functions in the error occurrence. There are two important functions in the C programming language to deal with errors; perror and strerror. The perror function is used to print the error description and the sterror function returns a string having error code.

Let's display the list of error codes by using errno.

Linux errno

The errno utility is used to looks up errno codes, macro names, and the corresponding descriptions. For example, if we provide ENOENT on a Linux system, it will display the code 2 and description " No such file or directory." If we provide the code 2, then it will display the ENOENT and its description.

If errno utility is not installed on our machine, it will display the error as follows:

Linux Error Codes

To install it, execute the below command:

By executing the above command, the moreutils package is installed on our machine that contains the errno utility.

Linux Error Codes

Display the List of Error codes

To display the list of the error codes, execute the command as follows:

The above command will display the list of error codes by RedHat. Consider the below output:

Linux Error Codes

Display the information of an error number

To display the information of a particular error number, execute the command as follows:

The above command will display the description of error number 2. Consider the below output:

Linux Error Codes

Display the information of an error name

To display the information of a particular error name, execute the errno command, followed by the error name. For example, to display the information of an error name 'ESRCH,' execute the command as follows:

The above command will display the information about the specified error name. Consider the below output:

Linux Error Codes

Display the error using strings

To display an error description by using a string from the description, execute the command as follows:

The above command will display the errors whose description contains string permission. Consider the below output:

Linux Error Codes

List of Linux system Errors

Following is a partial list of possible errors of Linux system:

Error codeError noDescription
EPERM1It is displayed if the operation is not permitted.
ENOENT2It is displayed if there is no such file or directory exists.
ESRCH3It is displayed if there is no such process exists.
EINTR4It is displayed for Interrupted system call
EIO5It is displayed for input/output error.
ENXIO6It is displayed if there is no such device or address exists.
E2BIG7It is displayed if argument list is too long.
ENOEXEC8It is displayed if there is an exec format error
EBADF9It is displayed in case of bad file descriptor.
ECHILD10It is displayed if there is no child process exists.
EAGAIN11It is displayed if resource is temporarily unavailable.
ENOMEM12It is displayed if the system cannot allocate memory.
EACCES13It is displayed if permission is denied.
EFAULT14It is displayed if there is a bad address.
ENOTBLK15It is displayed if Block device is required.
EBUSY16It is displayed if device or resource is busy.
EEXIST17It is displayed if file already exists.
EXDEV18It is displayed if there is invalid cross-device link.
ENODEV19It is displayed if there is no such device.
ENOTDIR20It is displayed if there is not a directory.
EISDIR21It is displayed if there is a directory.
EINVAL22It is displayed if there is an invalid argument.
ENFILE23It is displayed if there are too many open files in system.
EMFILE24It is displayed if there are too many open files.
ENOTTY25It is displayed if there is an inappropriate ioctl for device.
ETXTBSY26It is displayed if text file is busy.
EFBIG27It is displayed if the file is too large.
ENOSPC28It is displayed if there is no space left on device.
ESPIPE29It is displayed in case of illegal seek.
EROFS30It is displayed in case of read-only file system.
EMLINK31It is displayed if there are too many links.
EPIPE32It is displayed in case of broken pipe.
EDOM33It is displayed if numerical argument is out of domain.
ERANGE34It is displayed if numerical result is out of range.
EDEADLK35It is displayed if resource deadlock is avoided.
ENAMETOOLONG36It is displayed if file name is too long.
ENOLCK37It is displayed if no locks are available.
ENOSYS38It is displayed if function is not implemented.
ENOTEMPTY39It is displayed if directory is not empty.
ELOOP40It is displayed if there are too many levels of symbolic links.
ENOMSG42It is displayed if there is no message of desired type.
EIDRM43It is displayed if identifier is removed.
ECHRNG44It is displayed if channel number is out of range.
EL2NSYNC45It is displayed if level 2 is not synchronized.
EL3HLT46It is displayed if Level 3 is halted.
EL3RST47It is displayed if Level 3 is reset.
ELNRNG48It is displayed if the link number is out of range.
EUNATCH49It is displayed if protocol driver is not attached.
ENOCSI50It is displayed if there is no CSI structure available.
EL2HLT51It is displayed if Level 2 is halted.
EBADE52It is displayed in case of invalid exchange.
EBADR53It is displayed in case of invalid request descriptor.
EXFULL54It is displayed if exchange is full.
ENOANO55It is displayed in case of No anode.
EBADRQC56It is displayed for invalid request code.
EBADSLT57It is displayed for invalid slot.
EBFONT59It is displayed if there is bad font file format.
ENOSTR60It is displayed if device is not a stream.
ENODATA61It is displayed if there is no data available.
ETIME62It is displayed in case of timer is expired.
ENOSR63It is displayed in case of out of streams resources.
ENONET64It is displayed if machine is not on the network.
ENOPKG65It is displayed if package is not installed.
EREMOTE66It is displayed if object is remote.
ENOLINK67It is displayed if the link has been severed.
EADV68It is displayed for advertise error.
ESRMNT69It is displayed for Srmount error.
ECOMM70It is displayed if there is communication error on send.
EPROTO71It is displayed for protocol error.
EMULTIHOP72It is displayed for Multihop attempted.
EDOTDOT73It is displayed for RFS specific error.
EBADMSG74It is displayed for Bad message.
EOVERFLOW75It is displayed if value is too large for defined data type.
ENOTUNIQ76It is displayed if name is not unique on network.
EBADFD77It is displayed if file descriptor is in bad state.
EREMCHG78It is displayed if remote address is changed.
ELIBACC79It is displayed if we cannot access a needed shared library.
ELIBBAD80It is displayed in case of accessing a corrupted shared library.
ELIBSCN81It is displayed if there is .lib section in a.out is corrupted.
ELIBMAX82It is displayed if we are attempting to link in too many shared libraries.
ELIBEXEC83It is displayed if we cannot exec a shared library directly.
EILSEQ84It is displayed for an invalid or incomplete multibyte or wide character
ERESTART85It is displayed to inform that interrupted system call should be restarted.
ESTRPIPE86It is displayed if there is streams pipe error.
EUSERS87It is displayed for too many users.
ENOTSOCK88It is displayed for socket operation on non-socket.
EDESTADDRREQ89It is displayed if the destination address is required.
EMSGSIZE90It is displayed if message is too long.
EPROTOTYPE91It is displayed if the protocol is wrong type for socket.
ENOPROTOOPT92It is displayed if the protocol is not available.
EPROTONOSUPPORT93It is displayed if protocol is not supported.
ESOCKTNOSUPPORT94It is displayed if the Socket type is not supported.
EOPNOTSUPP95It is displayed if the Operation is not supported.
EPFNOSUPPORT96It is displayed if the protocol family is not supported.
EAFNOSUPPORT97It is displayed if the address family is not supported by protocol.
EADDRINUSE98It is displayed if the address is already in use.
EADDRNOTAVAIL99It is displayed if the system cannot assign requested address.
ENETDOWN100It is displayed if network is down.
ENETUNREACH101It is displayed if network is unreachable.
ENETRESET102It is displayed if network has dropped connection on reset.
ECONNABORTED103It is displayed if software caused connection abort.
ECONNRESET104It is displayed if connection is reset by peer.
ENOBUFS105It is displayed if there is no buffer space available.
EISCONN106It is displayed if the transport endpoint is already connected.
ENOTCONN107It is displayed if the transport endpoint is not connected.
ESHUTDOWN108It is displayed if the system cannot send after transport endpoint shutdown.
ETOOMANYREFS109It is displayed if there are too many references: cannot splice.
ETIMEDOUT110It is displayed if connection is timed out.
ECONNREFUSED111It is displayed if connection is refused.
EHOSTDOWN112It is displayed if the Host is down.
EHOSTUNREACH113It is displayed if there is no route to host.
EALREADY114It is displayed if operation is already in progress.
EINPROGRESS115It is displayed if the operation is now in progress.
ESTALE116It is displayed for Stale file handle.
EUCLEAN117It is displayed if structure needs cleaning.
ENOTNAM118It is displayed for not a XENIX named type file.
ENAVAIL119It is displayed if there are no XENIX semaphores are available.
EISNAM120It is displayed if there is a named type file.
EREMOTEIO121It is displayed for Remote I/O error.
EDQUOT122It is displayed if disk quota is exceeded.
ENOMEDIUM123It is displayed if there is no medium found.
EMEDIUMTYPE124It is displayed if there is wrong medium type.
ECANCELED125It is displayed if operation is cancelled.
ENOKEY126It is displayed if required key is not available.
EKEYEXPIRED127It is displayed if the key has expired.
EKEYREVOKED128It is displayed if the key has been revoked.
EKEYREJECTED129It is displayed if the key was rejected by service.
EOWNERDEAD130It is displayed if the Owner is died.
ENOTRECOVERABLE131It is displayed for no recoverable state.
ERFKILL132It is displayed if the operation is not possible due to RF-kill.
EHWPOISON133It is displayed if the memory page has hardware error.





Latest Courses