Uncategorized

Mac os x logout from command line

When you are inside a login shell, you have come there through a login - sounds straight forward, doesn't it? When you are inside an interactive shell, you haven't seen a login prompt anywhere immediately near the shell invocation. So you don't close the shell session with logout - you never logged in for that shell sesseion anyway. You use the exit command.

Apple Footer

Whenerver you open a new terminal window in OS X, you are invocating your shell implicitly as an interactive shell. Logout in this circumstance just doesn't make any sense - speaking from a unix standpoint of view. So basically, logout in an interactive shell is an alias to exit. This might be confusing but is a better solution than to implement the keyword goto into the language java just so as to issue an error message.

Remember that in OS X you are logged in in a windowing environment. You have never come to the windowing environment through a console login, using startx or something like that. Your terminal application is just another child of your windowing session, which is itself a child of a graphical login session.

For a little child to kill his grandfather by his own hand would be far too much cruelty for such a feeble mind, so logout won't be tampering anywhere up your tasks' heritage chain. If you now, on the other hand, had come to the windowing environment through startx, returned to the virtual console, pressed ctrl-z, set the windowing session bg and then typed logout But what the heck So basically, trying to do a complete logout via keyboard by aliasing the builtin logout command is, as interesting as it might be on first thought, on second thought trying to do it the unix way without getting to know, and understand, that is, the unix way on the first hand; on a unix operating system which does it's best to hide away it's unix heritage.

Sorry for the rumpling.

Hint Options

Just some thought from a traveler of platforms. And this is the reason why typing 'logout' in a Terminal window will close that window, while 'exit' merely quits the shell and leaves the window open. If you start a sub-shell by typing 'bash' in a Terminal window, then that sub-shell is a non-login shell and so 'logout' gives you an error message. In contrast, a new xterm window starts a non-login shell.

PeteVerdon on Mar 12, '05 I always use exit to close a terminal window, because I didn't log in to it and so that's what feels natural after years of Unix.

Logout User on Command Line in Mac OS X - agfox.com

Lost your password? Powered by the Parse. More Mac Sites: Macworld MacUser iPhone Central. When I'm primarily using the keyboard, I find it a bit annoying to have to switch to the mouse for anything even if just to logout.

How to Log Out Another User Without Logging In On Mac OS X

Normally, if you type logout in your Terminal window, your shell quits, but of course, you're still logged in to OS X. Add the following shell function to your. Depending on the state of your windows, you'll probably have to dismiss some dialog boxes in order to complete the logout, but this can be done using the keyboard as well. I'm not sure I'd replace the built-in logout function, as I've become quite used to using it to just logout from the Terminal.

Instead, you might want to change the command's name to logout2 , or something else, in order to prevent an accidental total logout. The following comments are owned by whoever posted them. This site is not responsible for what they say. IanWalker on Feb 21, '05 DavidRavenMoon on Feb 21, '05 From the Terminal Authored by: You can leave a terminal session also by typing "exit".

Force logout via command line

Excellent post! Thank you. Actually, each new Terminal window starts a "login shell". I can reboot the system easily enough and if things lock up it may be warranted using ' sudo reboot ' or the ' shutdown ' command, but, is it possible to simply log them out remotely, as can be done through Apple Remote Desktop?

Is there a nice way to do it, that lets them save files or possibly even cancel the logout?

If you enable the ssh sever remote login in sharing preferences dialog you will be able to ssh to the Mac from another machine and issue any command you want. But that is really dirty.

A log of the things I learn. I like comments!

Or just kill their logon process. This would pretty much be like having a windows box blue screen on you though. They would lose any unsaved work, etc. I'm not sure of a way to kill the user's login and allow them to possibly cancel that action or save file, though most apps under Lion will autosave. The Mac will wait a few moments while it does what it needs to do, then return you back to the Login screen.

Expect to wait almost two minutes before the login window appears.


  • how to write in different languages on mac!
  • serious eats stovetop mac and cheese!
  • Helpful answers;
  • the best music player application for mac!
  • how to edit images in mac os x!
  • incoming mail server apple mac;
  • Solved.tips.

In my testing the logout dialog wouldn't appear until ten or fifteen seconds after the command was given, then there's a sixty second wait and then there's the time it takes to log out. Another alternative is the approach given in the answer by user bmike to a question in Apple. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service , privacy policy and cookie policy , and that your continued use of the website is subject to these policies.

Home Questions Tags Users Unanswered. Log out graphical user from command line Ask Question. Just curious mostly. Clinton Blackmore. Clinton Blackmore Clinton Blackmore 2, 5 30 For example: Garry Harthill Garry Harthill 1 10 Presuming I've 'ssh'ed into the box -- can I log them out without rebooting?

You could do a sort of: I can't really think of any other way to do it more gracefully though. WerkkreW WerkkreW 5, 3 18 Any user with admin privileges can log them out using launchctl if it is a post You can see launchctl help for more information.