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 […]

The post Log a User Out from Command Line appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh

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»'

osascript is a really amazing utility, one that lets you change system volume, send iMessages, and identify app IDs. Readable automation commands? Priceless!

The post Log a User Out from Command Line appeared first on David Walsh Blog.


This content originally appeared on David Walsh Blog and was authored by David Walsh


Print Share Comment Cite Upload Translate Updates
APA

David Walsh | Sciencx (2021-12-14T10:49:24+00:00) Log a User Out from Command Line. Retrieved from https://www.scien.cx/2021/12/14/log-a-user-out-from-command-line/

MLA
" » Log a User Out from Command Line." David Walsh | Sciencx - Tuesday December 14, 2021, https://www.scien.cx/2021/12/14/log-a-user-out-from-command-line/
HARVARD
David Walsh | Sciencx Tuesday December 14, 2021 » Log a User Out from Command Line., viewed ,<https://www.scien.cx/2021/12/14/log-a-user-out-from-command-line/>
VANCOUVER
David Walsh | Sciencx - » Log a User Out from Command Line. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/12/14/log-a-user-out-from-command-line/
CHICAGO
" » Log a User Out from Command Line." David Walsh | Sciencx - Accessed . https://www.scien.cx/2021/12/14/log-a-user-out-from-command-line/
IEEE
" » Log a User Out from Command Line." David Walsh | Sciencx [Online]. Available: https://www.scien.cx/2021/12/14/log-a-user-out-from-command-line/. [Accessed: ]
rf:citation
» Log a User Out from Command Line | David Walsh | Sciencx | https://www.scien.cx/2021/12/14/log-a-user-out-from-command-line/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.