Thursday, February 12, 2004

Recovering forgotten root password

How to reset the root password if you forget it:



First, reboot the machine into single user mode. You do this by hitting space when FreeBSD says to "Hit [Enter] to boot immediately or any other key for command prompt", leaving you with the very cryptic "ok " prompt. Then type in :


ok boot -s


Once it finishes booting, then you can do:


# mount -u / ... mount root file system read/write

# mount /usr ... mount /usr file system (if seperate)

# passwd root .... change the password for root

Enter new password:

Enter password again:

# ^D ... enter ctrl-D to continue with startupbr>


This is all courtesy of the Complete FreeBSD book, by Lehey. I particularily love the chapter where he goes over the boot screen line by line, telling you what FreeBSD is doing.




1 comment:

  1. This is good when in /etc/ttys console is declared secure. You get stuck when /etc/ttys has console as insecure. In that case boot with install cd (only IDE cdrom worked in my case - no usb) than go to post install config -> fixit option -> use the live cd. Once your are in fixit console mount the HD and change console entry in /etc/ttys to secure, Reboot and than go single user mode as explained above and follow.
    Have fun
    -Yantragna

    ReplyDelete