Way to logout a user from the command line in OS X 10.9 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?
sudo launchctl bootout gui/$(id -u &lt;username&gt;)
or
sudo launchctl bootout user/$(id -u &lt;username&gt;)

Replace username with the target user's user name or replace the whole subshell with the user's uid.  This tells launchctl to teardown the users login session (gui specifically refers to the user's temporary login session, user specifies the users background processes).

You can log yourself out without the sudo to test this.

Note that this will ONLY work on macOS 10.11.x or newer (see launchctl help for more)