3

I installed fishfish(a user-friendly interactive command line shell) on a Linux server, later somebody uninstalled it but I don't know it. After I run chsh -s /usr/local/bin/fish without caution, I cannot login the server now. Error message "login: no shell: No such file or directory" showed up which apparently says that shell fish do not exist anymore.

The server provides only a CLI interface, so how can I change the login shell when I cannot even login?

  • Do you have access to a root account? – rahmu Jun 8 '12 at 8:48
  • @rahmu I ran chsh under account root. I changed root's shell. – xanpeng Jun 8 '12 at 9:14
  • @xanpeng You did it wrong, its chsh username_to_change from the root account. – Tim Jun 8 '12 at 13:57
  • 2
    And this would be why you should ALWAYS set the root account's shell to something basic that never gets undeleted, like sh or bash. – Shadur Jun 8 '12 at 14:20
  • @Shadur Yes, I did it wrong, lesson learned: should be more careful when you are root. – xanpeng Jun 8 '12 at 15:20
7

If you have access to the root account, you can change the shell for a user from there using chsh -u user -s $SHELL.

If you have access to the boot process, you can append init=$SHELL to be dropped to a single-user shell, where you can fix this, again with chsh -u user -s $SHELL (some systems using a two-stage boot with an initrd image may require you to use real_init instead). You will probably need to remount the filesystem containing /etc/passwd as read-write (using mount -o remount,rw / or similar).

Otherwise, if you can su into the user from another user, try su user -c $SHELL, or if you can ssh into the user, you could try something like ssh user@localhost $SHELL.

You could also boot into a live CD/USB, mount / and fix /etc/passwd manually.

| improve this answer | |
  • Thanks. (1) As I changed login shell for root himself, so I guess method #1 cannot work. (2) For method #2 "change boot process", I'm wondering how to remount the filesystem? I'm out of the shell, I cannot execute mount. I tried init=/bin/bash and `real_init=/bin/bash, neither of them worked. (3) For method #3, it cannot work as we have only one account, root, in the server OS. – xanpeng Jun 8 '12 at 10:01
  • @xanpeng I gave the command to remount the root filesystem (which is probably where you have /etc). You should be able to SSH in from another machine. – Chris Down Jun 8 '12 at 10:52
2

i have the same problem, this solution work for me:

  1. Boot with a live cd (i use debían 7.6) in live mode
  2. In live terminal, get root access running the command: passwd root
  3. Mount the disk of the partition of you crash distro
  4. Go to this disk and run this command: cat etc/shells
  5. With nano etc/passwd remove the fish references and put a valid console name of point 4
  6. Reboot and enjoy.
| improve this answer | |
1

When trying to login I was getting this message: Cannot execute /sbin/nologin: No such file or directory

This is what I did and it worked for me.

  1. I logged in the system with another account with super user privileges
  2. Enter the following command:

sudo chsh -u user -s $SHELL

where user is the account name with the problem

  1. Logout of the system
  2. Login with the account name that had a problem
| improve this answer | |
  • Correction the -u should be taken out – Yamija Munthali Aug 10 '16 at 10:23
0

I was also facing the same problem in Elementary OS Loki. To resolve the issue i performed the following

  1. firstly i remove everything related to zsh by sudo apt-get remove zsh && apt-get autoremove
  2. after that i edited the /etc/passwd file and found that shell of root user is not defined so i edited shell /bin/bash and this all help me to resolve the problem.
| improve this answer | |

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.