An Exit Code or Exit Status is an unsigned 8-bit integer returned by a command that indicates how its execution went.
An Exit Code of 0 indicates the command (program) was successful at what it was supposed to do. I think of it as zero means the program exited successfully with zero errors.
Any other Exit Code indicates that something went wrong.
Applications can choose for themselves what number indicates what went wrong; so refer to the manual of the application to find out what the application's Exit Code means.
The $? shell parameter provides the exit status (/ return value) of the most recently executed foreground pipeline.
#!/bin/bash #here's a command that will fail mv-l #just so we can see it's exit code: echo $?
Developers are free to specify their own exit codes, but must not interfere with the Reserved Exit Codes:
|Exit Code Number||Meaning|
|1||Catchall for general errors|
|2||Misuse of shell builtins (according to Bash documentation)|
|126||Command invoked cannot execute|
|127||"command not found"|
|128||Invalid argument to exit|
|128+n||Fatal error signal "n"|
|130||Script terminated by Control-C|
|255*||Exit status out of range|
Exit codes can be viewed using echo $?