Reset Root Password : FreeBSD

By | 2009/12/29

This post will outline how to reset the root password on FreeBSD. These instructions require local access to the machine and are available on FreeBSD versions 5.4 and greater.

Resetting the root password

As I mentioned above, resetting the root password and gaining administrative access to the machine requires local access to the server. Following the steps below should put you at an administrative prompt where you will be able to run the ‘passwd’ command to reset the password to a known value.

  1. Restart the server.
  2. When the “Welcome to FreeBSD” menu appears, press the [SPACEBAR] to pause the boot countdown.
  3. Select “4” which should be: Boot FreeBSD in single user mode.

After the machine boots you should be presented with a prompt:

When prompted Enter full pathname of shell or RETURN for /bin/sh:

Press the enter key, or enter the full pathname of your preferred shell. At this point you should be at a shell prompt, as the root user. The remaining step is to reset the password to a known value.

In order to make this change you’ll need to remount the filesystem(s) in read-write. Use the following two commands to make this change:

mount -u /

mount -a

Finally, reset the root password using the passwd command:

passwd root

At this point you should be able to reboot the machine, or type ‘exit’ to continue the boot process into its normal multi-user environment.

Troubleshooting

If you have problems regarding the “passwd” command not being found, or other similar issues, you may need to ensure that you have properly mounted any additional file systems. I might suggest using:

mount /usr

To ensure that your /usr partition is mounted (assuming it is on a separate partition).