2

Here is what happened: I used fish shell as default shell for pi account. I removed it but didn't change the default shell and now I am unable to log in. Luckily I have another account but it doesn't have sudo privilege (so I cannot just change /etc/passwd file).

I tried:

su --shell /bin/sh pi

or

su -s /bin/bash pi

So it won't try to use fish.

But it seems it is just ignoring the --shell option:

Password: 
Cannot execute /usr/bin/fish: No such file or directory

What else can I do to regain access to my pi account?

  • su just change the user, it is not the same as sudo. It doesn't need root permissions. You'll have to know the other user's password though. The "Password" out put was where I typed the pi user password. It worked, but it ignored my option to use sh shell and tried to use fish, which is not installed anymore – favba Dec 2 '16 at 1:45
  • Those are the permission on my /bin/su -rwsr-xr-x 1 root root 31092 Jun 5 2012 /bin/su Anyone can execute it. And I think it really wouldn't make sense otherwise. Maybe what you mean is that one cannot su to root user, which is true indeed. – favba Dec 2 '16 at 1:54
  • That is strange. I never modified it myself. Is this the default for Rasbian only? On my macbook it is also executable by anyone. – favba Dec 2 '16 at 1:58
3

But it seems it is just ignoring the --shell option:

Password: 
Cannot execute /usr/bin/fish: No such file or directory

This is correct behaviour, as (most likely) you have not added /usr/bin/fish to the /etc/shells. Consider this explanation from man su:

If the target user has a restricted shell (i.e. the shell field of this user's entry in /etc/passwd is not listed in /etc/shells), then the --shell option or the $SHELL environment variable won't be taken into account, unless su is called by root.


But to modify /etc/shells you need root permissions, so you are effectively locked out.

Your only option is to remove the SD card, mount it to another system, and modify the files accordingly (either /etc/passwd to regain access directly or /etc/shells to confirm the above).

  • This was what solved my problem. But mounting the sd card with NOOBS esoteric partitioning was a problem itself. I ended up finding a solution to it online and posted it as an answer here. – favba Dec 2 '16 at 3:52
0

I think you're looking for chsh

Try

chsh -s /bin/bash pi
  • This is what I got :( You may not change the shell for 'pi' – favba Dec 2 '16 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.