← All posts

FreeBSD. Recovering the root Password

FreeBSD logo

Sometimes we need to recover the password for the root account on Unix-like systems. For example, today I was changing root’s password and apparently mistyped it twice. I tried entering it about 5 times, but it wouldn’t let me in… I lost my patience and rebooted the server. Let’s get started!

1. Boot into “Single user” mode…

Select this mode at boot.

2. Try mounting the root partition

# mount -u /

If a message pops up saying this isn’t possible, the system most likely didn’t shut down properly, so do the following:

# fsck_ffs /dev/ad6s1a

Next, try mounting it again…

# mount -u /

3. If your /usr directory is on a separate partition, you will most likely need to mount it too…

# cat /etc/fstab

Look for the /usr partition here; mine was /dev/ad6s1f

Mount it…

# mount /dev/ad6s1f /usr

4. Change the password!

# passwd

Enter the password, and that’s it!

P.S. I think I accidentally pressed caps_lock, and after the reboot Caps Lock was off, so the password didn’t match…

Comments are closed. Read the original discussion in Russian →