About nixCraft

FreeBSD reset or recover root password

Posted by Vivek Gite [Last updated: September 19, 2007]

With FreeBSD 5.4 and above the booting procedure is slightly changed. Under ilder version of FreeBSD use boot -s option at Ok prompt.
However, with version FreeBSD 5.4+ you don't have to type any command. Here is the procedure to boot FreeBSD into a single user mode to reset root password.

In this tip I will explain how to boot FreeBSD into a single user mode to reset root password.

Procedure: Reset FreeBSD root user password

Step # 1: Start FreeBSD server/workstation

Step # 2: Press Enter key at boot loader

At Welcome to FreeBSD! boot menu press spacebar key to pause default booting

Type number 4 key (type 4 number) to boot into single user mode

(click to enlarge)

Next you will see following prompt from system:
When prompted Enter full pathname of shell or RETURN for /bin/sh:

Press Enter key to boot into single user mode. Next, you will be immediately dropped into a single user mode without a root password.

You need to remount / (root) file system in read and write mode with mount command, type following two commands:
# mount -u /
# mount -a

Setup a new password with passwd command:
# passwd

Next type exit command to boot FreeBSD into multi-user mode environment:
# exit
OR You can just reboot the system:
# sync;sync
# reboot

For more information read man pages of passwd and mount command.

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Daemon Dancing in the Dark Says:

    Recover lost root password…

    I’ve written abou this before, but nixCraft has a nice post on how to reset your root password if you forget it, using the new FreeBSD boot screen. Of course, if you done the tweak I point out here, to disable single user boot, you are, I think, prett…

  2. tamayekiyan Says:

    Dear Vivik:

    I can execute this instruction with version 6 but doesn’t work with lower versions.

    Is there any site that you can provide.

    Thanks,
    Tamayekiyan

  3. nixcraft Says:

    FreeBSD 4.x/5.x

    Allow FreeBSD to boot system and mount file system
    mount -u /

    if /usr is on separate partition, mount /usr too:
    mount /usr

    Now change password
    passwd root
    sync;sync

    Hit CTRL+D.

    Note that if the console was set as insecure in
    /etc/ttys file. If so you will need to boot from a CD / floppy into fixit mode. Next mount your hard-disk read-write to continue the repair.

  4. tamayekiyan Says:

    Dear nixcraft:

    I booted with freebsd 6.1 cd and proceed to sysinstall. I selected FIXIT and I got a root prompt at vty4.

    I have done the above instruction, after typing a command in the root # prompt; the system says: command not found.

    then I typed mount -u / - still i got command not found error. If i type ls, it will display command not found as well. If I type pwd - system say / (currently in the root directory).

    Am able to cd change directory to /usr and other subdirectory with no problems but mounting such device/directory - I have no luck at all.

    looking forward for your advises.

    Tamayekiyan.

  5. andrei Says:

    i followed the stept and it’s telling me that /usr was not properly dismounted

    help pls!!!

  6. PAVIlIOnX Says:

    i was follow all steps, but when i put in console the command “passwd” or “passwd root”, return me
    passwd: unknown user root.

    Please!!! help me!!!!!

  7. bleuken Says:

    Thanks for this post! I’m glad that I can use this to my problem on FreeBSD. I really forgot my password and I need to access the root (it’s the only user for the server and I need to fix it).

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , ,

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.