1
BashERRORNotableExit CodeHIGH confidence
General error
What this means
Exit code 1 is a catch-all for general errors. It signifies that a command failed to complete its task, but does not provide a specific reason. Many programs use it as a default failure code.
Why it happens
- 1A wide variety of issues, such as invalid arguments, file access problems, or internal logic failures.
- 2A script explicitly uses `exit 1` to signal a generic failure.
How to reproduce
A command fails for a reason not covered by a more specific exit code.
trigger — this will error
trigger — this will error
#!/bin/bash # 'ls' fails because the file does not exist ls /nonexistent-file echo "Exit: $?"
expected output
ls: cannot access '/nonexistent-file': No such file or directory Exit: 1
Fix
Examine stderr for error messages
WHEN When a command returns exit code 1
Examine stderr for error messages
mycommand || echo "Command failed with exit code $?"
Why this works
The error message printed to stderr by the failing command usually explains the specific cause of the failure.
What not to do
✕ Ignore the error
Exit code 1 indicates a definite problem that needs to be investigated.
Sources
Official documentation ↗
GNU Bash Manual
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev