Linux Commands Reference - Complete Linux Command Guide

Comprehensive Linux command reference with 150+ commands. Search, filter by category, and view detailed usage examples.

Share
Back to commands

exit

Exit the shell

Syntax

exit [N]

Common Options

NSpecify exit code (0-255)
0Success exit
1General error
2Misuse of shell command
126Command not executable
127Command not found
130Ctrl+C interrupt

Common Examples

exit

Exit current shell

exit 0

Success exit

exit 1

Error exit

exit $?

Use last command exit code

if [ -f file ]; then echo "found"; else exit 1; fi

Conditional exit

(exit 42); echo $?

Exit in subshell, get code

Related Commands

Related Tools

More Code & Dev Tools