Shell
$?
Exit status of the most recently executed command.
Ubuntu
Debian
Arch
Fedora
CentOS
SUSE
Alpine
macOS
FreeBSD
Verified: 2026-05-12
Syntax
$echo $?
Examples
$ls /tmp && echo $?
$false; echo $?
Typical use cases
?
Standard usage
$? --help
Note
0 means success, non-zero indicates an error condition.
Export