What chsh did when I type `chsh -s SHELL` and how to go back to previous SHELL?

1

I have mistakenly setting my user login shell to some unknown directory:([1]. Now, I can't login to this user. Every time I try to ssh, it always failed as if I enter the wrong password. I try to login using root and do su --shell=/bin/tcsh username and I got

su: /path/to/shell/i/set/previously: permission denied

To be clear, /path/to/shell/i/set/previously point to some directory, not to shell executable. I've tried to change my login shell on /etc/passwd back to /bin/tcsh with no luck:(. Always got the same permission denied error:(.

Now, I wonder what chsh did that make me unable to login even after I change the entry on /etc/passwd. Also, how do I get back my previous shell (/bin/tcsh)

Thank you.

ariefbayu

Posted 2009-09-11T02:18:06.583

Reputation: 931

Answers

1

Login as root and use:

chpass username

You'll be in a vi buffer with the user settings. Change the shell to /bin/tcsh and Bob's your uncle.

As for why, these settings are actually held in /etc/master.passwd. /etc/passwd is generated from that file. Read The Fine Manual for more.

Richard Hoskins

Posted 2009-09-11T02:18:06.583

Reputation: 10 260

Unknown command “chpass” ... and how do you do this if the root user is the one you changed? – endolith – 2009-11-21T08:26:56.913

@endolith Are you using freebsd? – Richard Hoskins – 2009-11-21T12:38:44.927