$ echo $?
Exit code reference
A job died with 137, or a script returned 127 and the file is sitting right there. An exit status is one byte, so the only values are 0 to 255, and most of the meaning comes from three conventions: the shell's own codes (126, 127), the 128 + N rule for a process killed by signal N, and the BSD sysexits.h range, 64 to 78. Nothing makes a program follow any of them, so each page says what the code usually means and what to check.
Signal numbers are Linux on x86 and arm64, which is what the 128 + N values below use; on FreeBSD some signals have other numbers, so the same death reports a different status. Names link to the signal reference.
Decode a status
Type a number to decode it. Anything above 255 wraps modulo 256, the way the kernel stores it.
36 codes
Shell and tool convention
Success.
General failure: the catch-all.
Usage error: bad options or arguments.
timeout(1) killed the command because the time limit expired.
timeout(1) itself failed, before running the command.
The command was found but could not be executed.
Command not found.
Exit status out of range, or ssh failed.
Killed by a signal (128 + N)
- 129SIGHUP (128 + 1)
Killed by SIGHUP: the controlling terminal went away.
- 130SIGINT (128 + 2)
Interrupted from the keyboard (Ctrl-C).
- 131SIGQUIT (128 + 3)
Quit from the keyboard (Ctrl-\), normally with a core dump.
- 132SIGILL (128 + 4)
Killed by SIGILL: the CPU hit an instruction it will not run.
- 133SIGTRAP (128 + 5)
Killed by SIGTRAP: a breakpoint or trace trap with nobody attached.
- 134SIGABRT (128 + 6)
The process called abort(), usually after a failed assertion.
- 135SIGBUS (128 + 7)
Killed by SIGBUS: a bad memory access that is not a plain segfault.
- 136SIGFPE (128 + 8)
Killed by SIGFPE, usually an integer divide by zero.
- 137SIGKILL (128 + 9)
Killed by SIGKILL: the process was not given a chance to clean up.
- 139SIGSEGV (128 + 11)
Segmentation fault: the process touched memory it does not own.
- 141SIGPIPE (128 + 13)
Wrote to a pipe nobody is reading.
- 143SIGTERM (128 + 15)
Asked to terminate politely, and did not handle it.
- 159SIGSYS (128 + 31)
Killed by SIGSYS: the process made a system call a filter forbids.
sysexits.h
- 64EX_USAGE
Command line usage error.
- 65EX_DATAERR
Input data was malformed.
- 66EX_NOINPUT
An input file did not exist or could not be read.
- 67EX_NOUSER
The addressee is unknown.
- 68EX_NOHOST
The host name is unknown.
- 69EX_UNAVAILABLE
A needed service is unavailable.
- 70EX_SOFTWARE
Internal software error.
- 71EX_OSERR
An operating-system error such as a failed fork.
- 72EX_OSFILE
A critical operating-system file is missing or unusable.
- 73EX_CANTCREAT
Could not create the output file.
- 74EX_IOERR
An I/O error occurred.
- 75EX_TEMPFAIL
Temporary failure: try again later.
- 76EX_PROTOCOL
The remote system violated the protocol.
- 77EX_NOPERM
Permission denied.
- 78EX_CONFIG
Configuration error.
No match. Try the number or a signal name, or search the whole site.
Sources: the GNU Bash manual (Exit Status), timeout in GNU coreutils, ssh(1), grep(1), sysexits(3) and signal(7). Spot one that's wrong? Tell Rod.