EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

Linux Error Codes

By Priya PedamkarPriya Pedamkar

Home » Software Development » Software Development Tutorials » Linux Tutorial » Linux Error Codes

Linux Error Codes

Introduction to Linux Error codes

In the Linux operating system, we are working on many components. While working, we are getting lots of errors. The same errors can be acknowledged by the Linux error codes. There are different error codes available as per the execution error. We can capture the error code with the help of the “echo” command also.

To fix the error message in the Linux level jobs/query or application-level job, it is mandatory that we need to understand the nature of the error, the error description, and the error code. Accordingly, we can fix the application or job on the Linux level.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

The error code utility i.e., “errno” is written by the Lars Wirzenius.

Syntax of Error Codes

errno [ OPTION ] [ STRING ] echo $?

  • errno: We can use the “errno” keyword in the syntax or command. It will take the two arguments as access OPTION and the string. As per the provided arguments, it will provide the error information as per the string or the error code.
  • OPTION: We can provide the different flags as options that are compatible with the “errno” command.
  • STRING: We can provide the short string as per the “error” define. It will provide the error information concerning the provided string.
  • echo $?: The echo command will also provide the error code. We need to use the “?” symbol with the echo command.

How Linux Error Codes Works?

In Linux, we are having a total of 134 error codes. Every error message or the failure in the Linux environment, it will have their error code. With the help of error code, we can fetch the error description and help to fix the issue or error message. If we will keep the same error message as it is then it will be a big impact on the server level.

When we are executing any command or job on the Linux level without any error then it will be fine. But if the Linux command will not be executed properly then the Linux compiler will notify with the relevant error message to the login user.

Below are the lists of error code information available,

Sr No Error Code Error Number Error Description
1 EPERM 1 It will print the error message if the operation is not permitted.
2 ENOENT 2 It will print the error message if there are no such files or directory exists.
3 ESRCH 3 It will print the error message if there is no such process exists.
4 EINTR 4 It will print the error message if any interrupted system calls.
5 EIO 5 It will print the error message if it is any input/output error.
6 ENXIO 6 It will print the error message if there is no such device or address exists.
7 E2BIG 7 It will print the error message if the argument list is too long.
8 ENOEXEC 8 It will print the error message if there is an exec format error.
9 EBADF 9 It will print the error message in it is a bad file descriptor.
10 ECHILD 10 It will print the error message if there are no child process exits.

Examples to implement Linux Error codes

Here are the following examples mention below

Examples #1 – Print the List

The “errno” utility is a very simple and common way to check the list of error codes in a Linux environment. It will print all the list of error codes with the error number and error description.

Popular Course in this category
Kali Linux Training (3 Courses, 3+ Projects)3 Online Courses | 3 Hands-on Projects | 21+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (5,486 ratings)
Course Price

View Course

Related Courses
Linux Training Program (16 Courses, 3+ Projects)Red Hat Linux Training Program (4 Courses, 1+ Projects)

Command :        

errno -l

Explanation :

As per the above command, we can print all the list of error codes available in the Linux environment. It will print the details information of error code like an error code name, error code number, and the description of the error code.

Output :

Linux Error Codes output 1

Example #2 – Information of Individual Error Number

By default, we are getting all the list of error code information. But we can also get the individual error number information as well.

Command:

errno 9

Explanation :

In the “errno” utility, we can get the specific information error information with the help of an error number. We have used the error no “9” and get the information of “error number 9” only.

Output :

Linux Error Codes output 2

Example #3 – Information of Individual Error Name

In the error codes, we can get the individual error number information. Similarly, we are having the functionality to print the individual error name information.

Command :

errno EBADF

Explanation :

As per the above command, we can get the specific information error information with the help of the error name. We have used the error name “EBADF” and get the information of “error name (EBADF)” only.

Output :

Linux Error Codes output 3

Example #4 – Error Code Information from the Input String

In the Linux environment, we are having the functionality to get the error code and error number information from the input string. We need to use the “-s” option with the “errno” utility.

Note: we need to provide the relevant input string as an input to the “errno” command.

Command :

errno -s access

Explanation :

When we don’t know the exact error number or name then we can use the relevant string to identify the error code and description of it. We have used the “access” string and get the related information of access.

Output :

output 4

Example #5 – Get the Error Code Information with “echo” Command

In the Linux ecosystem, we are having the functionality to check the quick error code information via the “echo” command. If it will return the “0” output then the command was executed fine. If it will return the output value except “0” then there are some issues in the command or job.

Command :

cat test_file.txt
echo $?

Explanation :

In screenshot 1 (a), we are getting the echo command output as “0”. Hence, it is an indication of the proper execution of the command. In screenshot 1 (b), we are getting the echo command output as “1”. Because the previous command was not executed successfully.

Output :

output 5.1

Screenshot 1 (a)

output 5.2

Screenshot 1 (b)

Conclusion

We have seen the uncut concept of “Linux Error Codes” with the proper example, explanation, and command with different outputs. Every error code is having its unique error name and the error number. The error codes are very important in terms of fixing the issues on command or job level.

Recommended Articles

This is a guide to Linux Error Codes. Here we discuss How Linux Error Codes Works and Examples along with the commands and outputs. You may also have a look at the following articles to learn more –

  1. Linux Mount Command
  2. Linux Inode
  3. Linux tac
  4. Linux Free Command

All in One Software Development Bundle (600+ Courses, 50+ projects)

600+ Online Courses

50+ projects

3000+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
Linux Tutorial
  • Advanced
    • Install VMware
    • Install GRUB
    • Chown Command in Linux
    • Linux Network Command
    • Configuring Linux Network Environment
    • DNS Configuration in Linux
    • Linux Users
    • Create User in Linux
    • DHCP Server in Linux
    • FTP Server in Linux
    • Linux Regular Expression
    • IP Command in Linux
    • Set IP Address in Linux
    • Tar Command in Linux
    • Dynamic Host Configuration Protocol
    • Linux Kill Signals
    • Linux File Permissions
    • Linux File System
    • Linux Create File
    • Linux Concatenate Files
    • Linux Join
    • Linux Process Management
    • Linux Proxy Server
    • Linux System Commands
    • Linux System Logging
    • NFS in Linux
    • Linux LVM
    • Linux Repository
    • Samba Server in Linux
    • Top Commands in Linux
    • Types of Shells in Linux
    • Shell Script Types For Linux
    • GCC Command in Linux
    • Monolithic Kernel
    • YARN Package Manager
    • Linux Sed Replace
    • Linux List Groups
    • Linux Container
    • Linux Find File by Name
    • Create Folder in Linux
    • Linux Move Folder
    • Linux Error Codes
    • Linux Automount
    • Linux HugePages
  • Basic
    • Introduction to Linux
    • What is Linux
    • Careers in Linux
    • How to Install Linux
    • How to Install Ubuntu
    • How to Install Ubuntu Server
    • How To Install Debian
    • Advantage Of Linux
    • What is Raid in Linux
    • What is Raid 5?
    • Raid 5 vs Raid 6
    • Careers in Linux Administration
    • What is Shell in Linux?
    • Bash Shell in Linux
    • Linux Emulator
    • Linux Operators
    • Linux Apps
    • Linux Keyboard Shortcuts
    • Linux Crontab
    • What is Raid Storage
    • What is Vmware
    • What is RedHat
    • What is Debian
    • Uses of Ubuntu
    • Career In RedHat
    • Linux Distributions
    • Linux From Scratch
    • Linux Format
    • Cheat Sheet Linux
  • Linux Commands
    • CAT Command in Linux
    • PS command in Linux
    • Mkdir Command in Linux
    • rmdir command in Linux
    • mv command in Linux
    • Linux rm Command
    • CHMOD Command in Linux
    • Zip Command in Linux
    • Linux Route Command
    • SCP Command in Linux
    • du Command in Linux
    • Less Command in Linux
    • Copy Command in Linux
    • Head Command in Linux
    • Help Command in Linux
    • Linux History Command
    • hostname Command in Linux
    • GREP Command in Linux
    • Linux Curl Command
    • Linux List Users
    • Linux List Directories
    • Linux Directory Permissions
    • Find Directory Linux
    • Linux User Permission
    • Linux Add User
    • Linux Delete User
    • Linux uniq
    • Linux Filter Commands
    • Linux sort Command
    • Linux Sort by Size
    • Remove dir Linux
    • Linux tr Command
    • Linux Touch Command
    • Linux More Command
    • Linux Cal Command
    • Linux OD
    • Linux Zcat
    • Linux tracepath
    • Linux Sleep
    • Linux bg Command
    • Linux WC
    • Linux Read
    • Linux Write
    • Linux Rename Command
    • Linux Free Command
    • Linux tac
    • Linux Shred
    • Linux wget
    • Linux Date
    • Linux Untar
    • Linux JQ
    • Linux Xargs
    • Linux Mount Command
    • Linux mdadm
    • Linux comm
    • Linux tee Command
    • Tail Command in Linux
    • Linux gzip
    • Linux Directory Structure
    • Linux Alias Command
    • Linux Inode
    • Linux Ping
    • Linux Watch Command
    • Linux Split Command
    • Linux Size
    • Linux Network Stack
    • Linux Diff Command
    • Vim Command in Linux
    • Linux nslookup
  • Kali Linux
    • Install Kali Linux
    • Kali Linux Uses
    • Kali Linux Commands
    • Kali Linux Repository
    • Kali Linux Packages
    • Kali Linux root password
    • Kali Linux Alternative
  • Interview Questions
    • Linux Interview Questions
    • Linux System Administration Interview
    • Red Hat Interview Questions

Related Courses

Kali Linux Training

Linux Training Course

Red Hat Training Course

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA Login

Forgot Password?

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - Kali Linux Training Learn More