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?
|
|
|||||||||
|
|
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. |
|||||||||||||||||||||
|
|
This has worked for me in the past: Log out (with confirmation)
Log out directly (no confirmation)
or
This way any running application will get noticed and can terminate in a safe fashion. |
|||||||||||||||||
|
|
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 Note that this will ONLY work on 10.10 or newer (see |
|||||
|
|
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. Check with |
|||
|
|
|
This does the trick for me.
To get some root privileges and the # prompt, then kill the processes.
And if it´s not all gone. Nuke em!
|
|||||
|
|
if you're logged with ssh to a remote computer you can logout by simply typing 'exit':
|
|||
|
|