# How do I recover from invalid rc.conf file



## viento (Jan 15, 2010)

I'm experimenting with FreeBSD in a virtual machine and attempted to clear the console screen after the system boots by adding "exec clear" to the end of /etc/rc.conf  Now, my system load and I can't login.  I receive the following message:

```
exec: clear: not found
Enter full pathname of shell or RETURN for /bin/sh:
```

How do I recover from my mistake?  I can't login and don't have access to modify that file.


----------



## fronclynne (Jan 15, 2010)

Do as it says, and press return.  Then issue 
	
	



```
fsck -p
mount -u -w /
mount -a -t ufs
vi /etc/rc.conf
```
or sub ee for vi (or ed(1), if you're nasty)


----------



## viento (Jan 15, 2010)

I need more learning time to be nasty.  vi will suffice for now.

Thanks, you solved my problem.


----------



## gordon@ (Jan 15, 2010)

Couple of notes about what you did here.

First, commands should not be put into rc.conf. It should only be used for defining variables.
Second, clear is a shell builtin. So exec clear isn't going to work as there is no binary by that name.


----------



## fronclynne (Jan 15, 2010)

I seem to recall that using vidcontrol(1) to change video modes would put the cursor at the top, & the allscreens_flags="MODE__NNN_" would do similarly.  Setting rc_startmsgs="NO" in /etc/rc.conf might suppress those last few output lines.  I don't know if there's a better/canonical way, though.

What gordon@ says is very true, rc.conf is read early enough in the booting process that any spurious commands are processed long before they would be of use if they worked in any case.


----------

