How to: OpenBSD reset root password

last updated in Categories OpenBSD, Sys admin, Tips

If you forgot your root password, you can simply reset it. The general procedure for resetting password is as follows (if you are a Linux user, see how to reset Linux root password):


a) At boot> prompt force openbsd to boot into a single user mode

b) Next mount file system in read-write mode

c) Run passwd command

d) Sync file system

e) Reboot and login normally.

Procedure to reset root password

At boot> prompt type boot -s to boot into single user mode:
boot> boot -s
Next you will see a message as follows:

Enter pathname of shell or RETURN for sh:

Just hit [Enter] key to load sh shell.
Next mount / and /usr file system in read-write mode:
# mount -uw /
# mount /usr

Finally set or change the password for root user, enter:
# passwd
Press CTRL+D to boot into multiuser mode or just reboot server:
# reboot

Further reading


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

1 comment

  1. The problem is that this method doesn’t work for many modern distros (like PC-BSD and openSUSE). They ask you for root password at boot time. In BSD, it is controlled, IIRC, by setting ‘secure’ in the /etc/ttys file for the tty. Not really sure how it is done in Linux. In openSUSE, there is a /etc/inittab file, and in there is a ‘what to do in single-user mode” comment that includes running /sbin/sulogin. Perhaps if this is commented out?

    Another discussion is here:

    This is how you can boot a Live CD and edit the /etc/shadow file to remove the root password.

    Have a question? Post it on our forum!