I want to logout my Mac OS X from the command line. My OS X version is 10.9.
I tried command
pkill -KILL -u uid, but this command didn't work out.
Is there a command that can be used to log out a user from the system using command line only, not AppleScript?
This has worked for me in the past:
Log out (with confirmation)
Log out directly (no confirmation)
This way any running application will get noticed and can terminate in a safe fashion.
To log out purely from terminal (or a remote ssh session), just kill the loginwindow process:
You could get fancy and specify the user if multiple users have a loginwindow process, but this is an easy one shot, no prompt way to end a user's graphical session.
If you have multiple users ....
Find the Process ID with:
Then kill that process and you logged that session out. But there are a lot of procceses left.