11

I have an account on my OS X Mavericks system that I want to disable so it cannot be used for login. I would not like to delete the account permanently but rather disable it temporarily.

I believe that this was possible in Lion – but maybe my memory plays tricks on me?

16

You can disable a user account by setting their shell to /usr/bin/false.

Either run chsh -s /usr/bin/false <username>, or change it in Users & Groups → Advanced Options. To change it back, run chsh -s /bin/bash <username>.

  • I was aware of this trick, but does it also apply to GUI logins? – mgd Jun 16 '14 at 12:18
  • 2
    @mgd Yes it does :) – grg Jun 16 '14 at 12:19
  • I just used this, and now (after re-enabling the account, which was an admin, btw) the account can't use the Terminal: login: /etc/shells: Permission denied. Did I do something wrong? – Cullub Jun 2 '16 at 22:52
  • 1
    This doesn't work any more on Mac OS X 10.13 High Sierra. You're still able to login via the Login Window – Paul Dec 25 '17 at 9:43
5

For Yosemite and newer, you can use

sudo dscl . create /Users/UserName IsHidden 1

Source: https://support.apple.com/en-us/HT203998

  • 5
    This doesn't actually disable the account, it just hides the username on the login page. There's still an 'Others' entry there where the hidden user can enter their username and password. – Stuart Hallows Oct 5 '15 at 11:38
4

Changing the login shell does not stop the GUI login, but does stop shell / ssh login.

The answer is given by: https://serverfault.com/questions/61214/how-can-i-disable-a-user-account-from-the-cli-with-mac-os-x-server#new-answer

With details on hiding given by: https://support.apple.com/en-au/ht203998

pwpolicy can both disable and enable users, without losing their password

To disable the user

pwpolicy -u username disableuser

To enable the user

pwpolicy -u username enableuser

Use dscl to hide the user so they don't show on login:

sudo dscl . create /Users/username IsHidden 1 

To show a hidden user

sudo dscl . create /Users/username IsHidden 0 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .