Log a User Out from Command Line
Automation is a system administrator, support agent, and tech savvy person's dream. Automating tasks via scripts remotely helps to get clients out of trouble or even the organization itself. Oftentimes big updates can require users log out. Logging a user out from command line is super easy on Macs!
To log a user out of macOS with a confirmation warning, execute the following from command line:
osascript -e 'tell app "System Events" to log out'
To force log out of macOS without warning, execute the following from command line:
osascript -e 'tell application "loginwindow" to «event aevtrlgo»'