What does exit code 1 mean in bash?
Exit code 1 is a general error — the command failed for an unspecified reason. Check stderr for the actual error message. It is the most common non-zero exit code and is used by most utilities to signal failure.
Quick Answer
Every bash command exits with a status code stored in `$?`. Zero means success; any non-zero value signals failure. When a cron job dies at 3am with no terminal attached, that number is often the only clue about what broke. Code 1 is a generic failure, 127 means the shell could not find the binary in `$PATH`, 130 means the process received SIGINT from Ctrl+C, and 137 typically means the Linux OOM killer sent SIGKILL. Ignoring `$?` lets a failed `cd` or `mkdir` cascade into commands running against the wrong directory. This browser tool maps any integer from 0 through 255 to a plain-English label, common causes, and representative commands that return that code. Type a number, browse the full table, or click Copy Handler to paste a trap block that prints the failing line and exits non-zero. The lookup runs entirely client-side — no install, no login, no data sent to a server.
What does exit code 1 mean in bash?
Exit code 1 is a general error — the command failed for an unspecified reason. Check stderr for the actual error message. It is the most common non-zero exit code and is used by most utilities to signal failure.
What is exit code 127 in bash?
Exit code 127 means "command not found." The shell could not locate the binary in any of the directories listed in $PATH. Check that the command is installed and that its directory is in your PATH.
How do I check the exit code of the last command in bash?
Run `echo $?` immediately after the command. This prints the exit code of the most recently executed foreground command. In scripts, capture it with `exit_code=$?` before running anything else.
What exit code means success in bash?
Exit code 0 always means success in bash and all POSIX-compliant shells. Any non-zero value signals failure. This convention applies to every command, script, and function in the shell.
An operational script system + a 30-function shared library + a 52-page field guide. The production layer the free snippets don't cover.
Get the Toolkit →Ten functions I source into every script on my own boxes — strict-mode setup, an ERR trap that names the failing line, lock and timeout wrappers, and cleanup that runs on every exit path. One email, no sequence.
intermediate · error-handling
Bash Error Handling with set -euo pipefail
Bash keeps going after a failed command, so a broken cd followed by rm -rf hits the wrong directory. set -euo pipefail stops the script at the first failure.
beginner · conditionals
Bash If/Else Examples
The wrong comparison operator makes a bash if statement fail silently on unexpected input. if/else, elif, integer and string tests, file checks, and quoting.
beginner · path
Fix "bash: command not found": PATH, Typos, hash -r, CRLF and Cron
Fix bash: command not found: check PATH, typos, a stale hash table, CRLF line endings and sudo's PATH. What exit code 127 means in scripts, cron and CI logs.
beginner · permissions
Fix "Permission denied" in Bash: chmod, noexec, Directories and Exit 126
Fix Permission denied when running a bash script: chmod +x, directory search bits, noexec mounts and ownership. Decode exit 126 and the cases chmod cannot fix.