Finish work in a remote shell opened through SSH.
End the shell normally and close the connection.
Which command can be used?
exit or logout normally terminates the login shell, which closes the SSH session while leaving the remote system running.
Detailed explanation
exitCorrect. exit closes the remote shell and normally ends the SSH session.
Correct. exit closes the remote shell and normally ends the SSH session.
haltIncorrect. halt stops the remote system.
Incorrect. halt stops the remote system.
kill -9 $$Incorrect. Killing the shell forcefully is unnecessary and can skip cleanup.
Incorrect. Killing the shell forcefully is unnecessary and can skip cleanup.
shutdown nowIncorrect. shutdown stops the remote system rather than only ending the session.
Incorrect. shutdown stops the remote system rather than only ending the session.
Try it yourself
An example you can run in a temporary verification environment.
help exitExpected result
Bashのexit builtin説明。現在のshellでは実行しないKey points
- exit
- Normal shell termination
- The system remains running
Notes
- Environment: Bash 5.2/OpenSSH 9.x
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.