logout - macOS
Overview
The logout command allows you to end your current macOS user session and return to the login window. It’s primarily used when you need to switch to a different user account or terminate your session remotely.
Syntax
logout [options]
Options/Flags
None
Examples
- Simple logout:
logout - Logout remotely using SSH:
ssh user@remote-mac "logout" 
Common Issues
- “logout: not login shell”: This error occurs when you attempt to run 
logoutfrom a non-interactive shell. Ensure you’re running it from a Terminal window or an interactive SSH session. 
Integration
- Combine with 
sudo: Usesudo logoutto log out as root or another user with administrative privileges. - Chain with 
sleep: Usesleep X; logoutto automatically log out after a specified delay in seconds (X). 
Related Commands
login: Starts a new user session.su: Switches to a different user account without logging out.screen: Creates a virtual terminal where multiple sessions can run simultaneously.