-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux true false Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to true and false on Linux, covering Arch Linux, CachyOS, and other distributions including boolean commands, exit codes, and script logic.
Basic usage:
# true always succeeds
true
# Exit code: 0 (success)Basic usage:
# false always fails
false
# Exit code: 1 (failure)Verify exit code:
# Check exit code
true
echo $?
# Output: 0 (success)
false
echo $?
# Output: 1 (failure)Conditional logic:
# In if statement
if true; then
echo "This runs"
fi
if false; then
echo "This doesn't run"
fiEndless loop:
#!/bin/bash
while true; do
echo "Running..."
sleep 1
donePlaceholder command:
#!/bin/bash
# Placeholder for future code
if condition; then
true # Do nothing for now
else
echo "Error"
false # Indicate failure
fiBoolean testing:
#!/bin/bash
if some_command; then
true # Success path
else
false # Failure path
fiLogical operations:
# Short-circuit AND
command1 && true
# Short-circuit OR
command1 || falseCheck installation:
# true and false are part of coreutils
# Usually pre-installed
# Check commands
which true
which falseThis guide covered true and false usage, exit codes, and script logic for Arch Linux, CachyOS, and other distributions.
- test Guide - Conditional testing
- Bash Scripting Guide - Scripting basics
-
true Documentation:
man true -
false Documentation:
man false
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.