exit
Quick Reference
Command Name:
exit
Category:
shell builtin
Platform:
Linux/Unix
Basic Usage:
Common Use Cases
- 1
Script termination
End script execution with a specific status code
- 2
Error handling
Exit scripts when errors occur to prevent further processing
- 3
Shell termination
Close the current shell session
- 4
Conditional termination
Exit scripts based on specific conditions or user input
Syntax
exit [n]
Options
Option | Description |
---|---|
n |
Exit with status code n. If n is omitted, the exit status is that of the last command executed. |
Examples
How to Use These Examples
The examples below show common ways to use the exit
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.