19

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?

3 Answers 3

18

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>.

4
  • I was aware of this trick, but does it also apply to GUI logins?
    – mgd
    Jun 16, 2014 at 12:18
  • 2
    @mgd Yes it does :)
    – grg
    Jun 16, 2014 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, 2016 at 22:52
  • 2
    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, 2017 at 9:43
15

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 
2
  • This should be the accepted answer. It worked on regular accounts. But can this also work on service accounts? Feb 24, 2020 at 9:09
  • Sorry, don’t have a server to test it on. The account disabled marks the account as disabled in the password database. Should work on all macs using OSX
    – Tom Hallam
    Feb 25, 2020 at 17:11
5

For Yosemite and newer, you can use

sudo dscl . create /Users/UserName IsHidden 1

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

1
  • 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. Oct 5, 2015 at 11:38

You must log in to answer this question.

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