Log a User Out from Command Line

By  on  

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!

Recent Features

  • By
    CSS Gradients

    With CSS border-radius, I showed you how CSS can bridge the gap between design and development by adding rounded corners to elements.  CSS gradients are another step in that direction.  Now that CSS gradients are supported in Internet Explorer 8+, Firefox, Safari, and Chrome...

  • By
    9 Mind-Blowing WebGL Demos

    As much as developers now loathe Flash, we're still playing a bit of catch up to natively duplicate the animation capabilities that Adobe's old technology provided us.  Of course we have canvas, an awesome technology, one which I highlighted 9 mind-blowing demos.  Another technology available...

Incredible Demos

Discussion

    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!