Reset lost root password
This guide will show you how to reset a forgotten root password. Several methods are listed to help you accomplish this.
Warning: An attacker could use some of the methods mentioned below to break into your system. No matter how secure the operating system is or how good passwords are, having physical access amounts to loading an alternate OS and exposing your data, unless you use data-at-rest encryption.
Using sudo
If you have installed sudo and have configured permissions for either the wheel
group or a user whose password you recall, you can change the root password by running sudo passwd root
.
Using the debug shell
- Append
systemd.debug_shell
to the kernel parameters. - This will do a normal boot but start
debug-shell.service
which runs a root shell (/bin/sh
) ontty9
. PressCtrl+Alt+F9
to access it. - Use the passwd command to create a new password for the root user.
- When done, stop
debug-shell.service
.
Using bash as init
- Append the
init=/bin/bash
kernel parameter to your boot loader's boot entry. - Your root file system is mounted as read-only now, so remount it as read/write:
mount -n -o remount,rw /
. - Use the passwd command to create a new password for the root user.
- Reboot by typing and do not lose your password again!
Using a LiveCD
With a LiveCD a couple methods are available: change root and use the command, or erase the password field entry directly editing the password file. Any Linux capable LiveCD can be used, albeit to change root it must match your installed architecture type. Here we only describe how to reset your password with chroot, since manual editing the password file is significantly more risky.
Change root
- Boot the LiveCD and mount the root partition of your main system.
- Use the command to set the new password (you will not be prompted for an old one).
- Unmount the root partition.
- Reboot, and enter your new password.
gollark: For any actual high-throughput writing I just use a computer, because anything else would be silly.
gollark: I also end up writing in a weird pseudocursive if trying to be fast.
gollark: It's just like a spinning ball, but not a ball and it isn't spinning. Simple.
gollark: Some actually-true things are notoriously annoying to explain in words.
gollark: Blood-brain barrier.
This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.