# How to access FreeBSD when I can't log in



## fred6633 (Jul 8, 2010)

Hello,

I followed a stupid tip I found to make bash default shell.
I typed this as root:
`chsh -s /usr/local/bin/bash`

Now I can't login.
When I come to the login and type "root" I get an error

```
/usr/local/bin/bash: No Such file or directory.
```
I read that I have to edit /etc/passwd.

Can I access the file system from the CD?

Fred


----------



## zeiz (Jul 8, 2010)

Was bash installed on your system?
`ls /var/db/pkg | grep bash`


----------



## jalla (Jul 8, 2010)

I guess the solution to this problem must have been rehashed numerous times both in this forum and others.
Basically you have to boot to single-user mode, mount your partitions (mount -atufs) and run vipw to reset your shell to something sensible (in every meaning of the word).


----------



## Alt (Jul 8, 2010)

fred6633 said:
			
		

> I followed a stupid tip I found to make bash default shell.
> I typed this as root:
> >chsh -s /usr/local/bin/bash
> 
> Now I can't login.


I bet you found it on linux forums :e



			
				fred6633 said:
			
		

> Can I access the file system from the CD?


Yes and after edit you will must run pwd_mkdb with -d key to remake password databases


----------



## phoenix (Jul 8, 2010)

Or, just run *chsh* again, pointing it at the correct shell.  No need to muck around with /etc/passwd, pwd_mkdb, vipw, etc.


----------



## Alt (Jul 8, 2010)

On live cd he will change shell in memory image xD

Btw i assume this tool little buggy, cus of (documented)ignoring /etc/shells and not checking binary exists at all..


upd: fred6633, you can try login as other user, then `su -m`, then chsh (this will not work in some cases)


----------



## Oxyd (Jul 9, 2010)

Alt said:
			
		

> On live cd he will change shell in memory image xD



He can boot into live CD, mount his on-disk installation, and then chroot into it: [cmd=]chroot /where/you/mounted/your/root /bin/sh[/cmd]. Then just run chsh, set the shell to something sensible, umount the disk and reboot.


----------



## Alt (Jul 9, 2010)

Ok ok xD
Now we know restoring is  possible haha


----------



## SirDice (Jul 9, 2010)

No need to muck about with boot or live CDs. Just boot to single user mode. Hit enter when asked to run /bin/sh. Then do the following:


```
fsck -y
mount -u /
mount -a -t ufs
swapon -a
```

Now change the root shell back to csh:
`# chsh -s /bin/csh`

Do NOT change root's shell again!


----------



## phoenix (Jul 9, 2010)

SirDice covered it.  I was talking about booting into single-user mode to run chsh, not off a LiveCD.


----------



## kpa (Jul 9, 2010)

Alt said:
			
		

> Btw i assume this tool little buggy, cus of (documented)ignoring /etc/shells and not checking binary exists at all..



Chsh and other similar utilities have to able to change the user's shell to nonexistent files as well.


----------

