Linux command
exit 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Exit shell with
exit
Exit with specific
exit [1]
Exit on error
set -e; exit
说明
exit is a shell builtin that terminates the current shell or script. An optional exit status is passed to the parent process; 0 conventionally indicates success. In scripts, exit immediately stops execution. In interactive shells, it closes the session. The exit status is available to the parent process via $? in shell scripts. Exit codes have conventional meanings: 0 for success, 1 for general errors, 2 for misuse, 126-127 for execution issues.
FAQ
What is the exit command used for?
exit is a shell builtin that terminates the current shell or script. An optional exit status is passed to the parent process; 0 conventionally indicates success. In scripts, exit immediately stops execution. In interactive shells, it closes the session. The exit status is available to the parent process via $? in shell scripts. Exit codes have conventional meanings: 0 for success, 1 for general errors, 2 for misuse, 126-127 for execution issues.
How do I run a basic exit example?
Run `exit` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
Where can I find more exit examples?
This page includes 3 examples for exit, plus related commands for nearby Linux tasks.