Why EXIT codes are Important in Linux?

Each Linux command returns a status code when it terminates normally or abnormally known as Exit codes. Basically these are numbers between 0 and 255, which is returned by any Unix command when it returns control to its parent process.

We can use values from exit status in the shell script to display an error message or take some sort of action with If-Else conditions.

Extracting the exit codes

$ echo $?

after running above command you will get Exit code as per your last command status.

Exit status 0

Exit status 1

Here are some list of most common exit codes for Linux:

DevOps