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.

  • Could you mount your disc on another mac and edit it that way? – Solar Mike Aug 08 '17 at 19:19
  • Your comment becomes a hint and I come up with a simple idea, recover my Mac from TimeMachine. Thanks a lot! – Yumenosuke Koukata Aug 09 '17 at 02: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 09 '17 at 17:55

2 Answers2

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

nohillside
  • 100,768
bmike
  • 235,889
  • 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 08 '17 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! – Yumenosuke Koukata Aug 09 '17 at 02: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 09 '17 at 03:18
  • oh, that's a good idea! I'll try next time! (I hope no next time...) Thanks! – Yumenosuke Koukata Aug 09 '17 at 10:13
  • Could ln /usr/local/bin/false to whatever shell it's suppose to go. – historystamp Dec 25 '18 at 23:05
-2

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

  • 2
    How can the OP run that - How can they login? – mmmmmm Feb 16 '21 at 18:27
  • 1
    @mmmmmm just create a new admin user using System Preferences. Who's OP btw? – arturasmckwcz Feb 16 '21 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 '21 at 20:10
  • 1
    And if you are creating nbew users much better to use bmike solution – mmmmmm Feb 16 '21 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. – arturasmckwcz Feb 16 '21 at 20:50
  • Yes I understand that you need a new admin user but I know a reasonable amount The question and answer don't say that and most users need to have all the steps listed – mmmmmm Feb 16 '21 at 21:09
  • Please reread the question. The user was logged out and can only boot into recovery or single user. Which steps do they need to take now (the proposed command alone won‘t work)? – nohillside Feb 17 '21 at 08:26