Session and utilities
The false command
Does nothing and exits with code 1, the error code. The counterpart of true.
Most useful options
--helpPrints the help of /usr/bin/false. The bash builtin prints nothing with this option--versionPrints the version of /usr/bin/false. The bash builtin does not show itCopy-ready examples
$ false || echo falloexits with an error, so the right side of || runs.Example output
fallo
$ false; echo $?shows the exit code of the last command: 1.Example output
1
$ false && echo no se ve&& does not run the right side after a failure, so it prints nothing.$ /usr/bin/false --help | head -n 1the help of the external program, which the builtin does not offer.Example output
Usage: /usr/bin/false [ignored command line arguments]
You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| bash: nodir/x: No such file or directory | The redirection fails before false runs. The exit code is 1, the same one false returns, so it does not tell the cause apart. | Create the folder with mkdir nodir or fix the path before redirecting. |
| bash: fals: command not found | Typo: there is no fals command. The shell returns 127, not 1. | Write false in full. type false confirms it is a bash builtin. |
Typical mistakes
- With && and ||, a false changes the path: false && echo x prints nothing, but false || echo x does print.
- In a script running with set -e, a bare false that returns an error stops the execution.
- Like true, it prints nothing: the failure only shows in $?, so check it with || or with if.
Differences from similar commands
/usr/bin/false: is the standalone program. It accepts --help and --version; the bash builtin does not.- true: is the counterpart: it exits with 0. If you want to invert an exit code, put ! before the command.
- exit: closes the shell or the script with the code you pass. false only returns 1 and lets the flow continue.
FAQ
Why does it not print any error?
It has nothing to say: its job is to return 1. Any message is written by whoever calls it.
Can it force a failure in tests?
Yes: in a script you can put false to simulate a failing command and check that the error handling reacts.
Why not use exit 1?
exit 1 closes the shell or the script. false only returns 1 and lets the flow continue, which fits && and ||.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course