exit status
also: return code, exit code, return status
A numeric code returned by a command or process to indicate whether it succeeded or failed, with 0 meaning success and non-zero values indicating specific errors.
Every command or process in Linux produces an exit status (also called a return code) when it completes. This is a single integer value that the parent process uses to determine what happened—whether the command worked correctly or encountered an error.
By convention, an exit status of 0 means the command succeeded, while any non-zero value indicates failure. Different non-zero codes can represent different error conditions. For example, a file-not-found error might be 2, while a permission denied error might be 1.
You can check the exit status of the most recent command using the special variable $? in bash: ls /nonexistent; echo $? will print a non-zero exit code. Exit statuses are essential for shell scripting, allowing you to write conditional logic based on command success or failure.