Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Sometimes I impress myself with my ability to screw things up: I changed the default shell of root with the chsh command, problem is I forgot to put in the full path. Now I can't log in as root. Is there a file somewhere that I can edit to change roots' default shell?

share|improve this question

4 Answers 4

up vote 2 down vote accepted

Yes, it's in /etc/passwd, but you'll need to be logged in as root to change it. You've said you can't log in now, but do you still have a live root window from before the change?

share|improve this answer
    
Or you could boot with a live CD/DVD or you could use sudo vi /etc/passwd if it is allowed for your non-root user (which hopefully exists). Also su root -c 'vi /etc/passwd' should work without a default shell. –  bmk Mar 16 '11 at 11:27
    
a catch-22 for sure. I don't have sudo set up but I do have separate user. root is logged out. It's a VPS so no CD/DVD available. Guess I'll have to re-install? –  breez Mar 16 '11 at 11:35
    
Do your VPS provider offer some kind of rescue system? –  Sven Mar 16 '11 at 11:36
    
brilliant, the VPS control-panel had a custom java console app which uses its own shell. Was able to change the passwd file as suggested, can now log in as root. Resolved! Thanks guys. –  breez Mar 16 '11 at 11:44

The shell for an user is specified in /etc/passwd, it's the last entry in each line; example:

root:x:0:0:root:/root:/bin/bash

In this case, the shell is /bin/bash.

Of course, you will have to log in as root in order to edit it, which in your case could be... difficult. If you have other user accounts on the system, you can log in as one of them and then use sudo to act as root and edit the file.

share|improve this answer

You can edit the /etc/passwd file and change the first line to be like:

root:x:0:0:root:/root:/bin/bash
share|improve this answer

If it's a VPS, ask the company to shut down the VM and mount your partition from Domain0 and modify yout /etc/passwd file (I guess they are providing VM on Xen).

share|improve this answer
    
That's quite a big guess... –  Massimo Mar 16 '11 at 20:26

Your Answer

 
discard

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.