Shell Exit Codes Cheat Sheet
What a process's exit code is telling you — from the standard 0/1 pair to signal-related codes like 137 (OOM kill) and 130 (Ctrl+C).
Every process exits with a code from 0 to 255. 0 means success; any other value signals failure, and the specific number often tells you why — 127 means the shell couldn't find the command at all, 126 means it found it but couldn't execute it.
Codes at 128 and above usually mean the process was killed by a signal: subtract 128 and you get the signal number. 137 = 128 + 9 (SIGKILL) is the classic 'my process got OOM-killed' code; 130 = 128 + 2 (SIGINT) means someone hit Ctrl+C.
Standard codes
| Code | Meaning | Example |
|---|---|---|
0 | Success | exit 0 |
1 | General error / catchall | exit 1 |
2 | Misuse of a shell builtin | incorrect command usage |
126 | Command found but not executable | permission denied on the file |
127 | Command not found | typo, or binary missing from PATH |
Signal-related (128 + signal number)
| Code | Meaning | Example |
|---|---|---|
130 | Terminated by Ctrl+C (SIGINT, 2) | 128 + 2 |
137 | Killed (SIGKILL, 9) — often an OOM kill | 128 + 9 |
139 | Segmentation fault (SIGSEGV, 11) | 128 + 11 |
143 | Terminated (SIGTERM, 15) | 128 + 15 |
Shell-specific
| Code | Meaning | Example |
|---|---|---|
$? | Last command's exit code (bash/zsh) | echo $? |
128 | Invalid argument to exit | exit "abc" |
255 | Exit status out of range | a value above 255 wraps around |