Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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
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

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.

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

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.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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