Close another user's session
Can I close their sessions from the terminal ? (even if it means closing all their open applications without saving)
sudo killall -u user loginwindow
#!/bin/zsh -f
if [[ $OSTYPE[7] -lt 7 ]];then
print "Fast User Switching is not available in OSX version $os_version"
return 1
fi
if [[ -z $1 ]]; then
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
else
USERID=`id -u $1`;
if [[ -z $USERID ]]; then
return -1;
fi
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID $USERID
fi
sudo killall -u user
loginwindow
Where user is the username of the account you want to
kill.
Note that this is fairly unclean and won't give apps
a chance to clean up after themselves, but it should
work.
Close another user's session