4

I really messed up! Since I ran my Mac with the command below

chsh -s /usr/local/bin/false

Several minutes later, I noticed my Mac logged out by itself. So, I tried to log back in by clicking 'change user' But I can't see my administer account there.

I guess 'false' is not a loggin-able shell, that's why my account is hidden.

I'm trying to change my shell with Terminal.app on recovery mode or single-user-mode (but both are read-only).

So right now, I want to know if there's any solutions that might be able to fix this problem.

3
  • Could you mount your disc on another mac and edit it that way?
    – Solar Mike
    Aug 8, 2017 at 19:19
  • Your comment becomes a hint and I come up with a simple idea, recover my Mac from TimeMachine. Thanks a lot! Aug 9, 2017 at 2:06
  • Please add your system version. BTW I can't comprehend this error: chsh -s /usr/local/bin/false doesn't do anything bad in my Sierra VM - user bash is still /bin/bash and reboot/login is possible...
    – klanomath
    Aug 9, 2017 at 17:55

2 Answers 2

1

OK - bummer situation, but probably pretty easy to get around.

  1. Boot in single user mode, mount the drive as read&write by running /sbin/mount -uw /, remove the /var/db/.AppleSetupDone file and make a new admin account
  2. Use that admin account to change back the shell for your user.
  3. Log out and check your account.
  4. Clean up the “temporary” admin account if you wish.

Nothing can go wrong, except for perhaps FileVault or no backup or a firmware password so if you can finish a backup or might have another admin account already - using that would be much better in case the above outline isn’t workable for you.

iMac is stuck in a login loop

https://support.apple.com/en-us/HT202860

5
  • 1
    There might be a better way to safely chsh in single user mode, but I know this will work and haven’t tested the alternative. I’ll vote for a good answer that has a better option or feel free to edit mine to make it better if you know the steps are safe.
    – bmike
    Aug 8, 2017 at 19:36
  • I couldn't remove that file from single-user-mode or recovery-mode because they are read only mode. (Perhaps I have a shallow understanding of the system.) However, I think that's right. If I can make admin account I can run any command as an administer and fix this situation. I don't want to give up to fix with the way for a better understanding of BSD, but I also need to recovery asap, I'm recovering from TimeMachine backup. Thanks a lot! Aug 9, 2017 at 2:21
  • For next time @yumenosuke /sbin/mount -uw / it should be printed in the instructions a line or two before the prompt gets shown
    – bmike
    Aug 9, 2017 at 3:18
  • oh, that's a good idea! I'll try next time! (I hope no next time...) Thanks! Aug 9, 2017 at 10:13
  • Could ln /usr/local/bin/false to whatever shell it's suppose to go. Dec 25, 2018 at 23:05
-2

try sudo cp /bin/bash /usr/local/bin/false

7
  • 2
    How can the OP run that - How can they login?
    – mmmmmm
    Feb 16, 2021 at 18:27
  • 1
    @mmmmmm just create a new admin user using System Preferences. Who's OP btw? Feb 16, 2021 at 19:13
  • 1
    OP is Original Post or Poster - and how were we to know tyhat you need to create a new user
    – mmmmmm
    Feb 16, 2021 at 20:10
  • 1
    And if you are creating nbew users much better to use bmike solution
    – mmmmmm
    Feb 16, 2021 at 20:11
  • 1
    I see. I don't believe one can get away without creating a new admin user, because the shell path is somewhere deep in opendirectoryd files which are binary. The only other way to login is the GUI. Feb 16, 2021 at 20:50

You must log in to answer this question.

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