ubuntu How to reset lost root password on Ubuntu 16.04 Xenial Xerus Linux

This guide will provide you with an information on how to reset lost root ( administrator ) password on Ubuntu 16.04. This guide assumes that you have the actual physical access to your Ubuntu 16.04 Linux box.

Reboot to Grub Menu

In the first step you need to reboot your Ubuntu 16.04 Linux box to Grub's menu. If the Ubuntu 16.04 is the only installation available keep pressing SHIFT after you start your computer until GRUB's menu appears: reboot your Ubuntu 16.04 Linux box in Grub's menu

Edit Grub Menu

Once you reboot to Grub menu, select the first menu item or the menu item you normally use to boot your Ubuntu system and press e to edit:
Edit ubuntu's grub menu


SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


Alter boot menu

Once in the Grub's boot menu edit mode use navigation arrows to locate a line starting with linux and edit it to include read-write mode rw and init=/bin/bash. For example
FROM:

linux     /boot/vmlinuz-4-4.0-22-generic root=UUID=43ad24d3-e\
c5b-44ee-a099-a88eb9520989 ro  quiet splash $vt_handoff

CHANGE TO:

linux     /boot/vmlinuz-4-4.0-22-generic root=UUID=43ad24d3-e\
c5b-44ee-a099-a88eb9520989 rw init=/bin/bash

Edit ubuntu's grub item to init=/bin/bash
Once ready press CTRL+x or F10 to boot.

Reseting root's password

If all went well you should now see root shell command line and your root partition should be mounted with read/write flags. To confirm run:

root@(none):/# mount | grep -w /

Edit ubuntu
Now we are ready to reset root's password. To do so, simply run passwd command with no arguments. When prompted enter your new root password:

root@(none):/# passwd

password reset with passwd
All done. Your root's password is now reset.



Reboot System

Reboot your system using the following linux command:

root@(none):/# exec /sbin/init

Troubleshooting

Enter new UNIX password:
Retype new UNIX password:
passwd: Authentication token manipulation error
passwd: password unchanged

Your root partition is mounted read-only. Try:

# mount -o remount,rw /

to resolve this issue.


[ end Kernel panic - not syncing: Attempted to kill init! exit code=0x0007f00

Make sure that you removed splash boot option when editing grub's menu item.


When trying to reboot with reboot command I get:

Failed to connect to bus: No such file or directory
Failed to talk to init daemon.

Ignore, and reboot with:

# exec /sbin/init
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
Logowanie za pomocą kluczy Secure Shell
Viewed 1416 times since Thu, May 24, 2018
Extending Linux LVM partitions script
Viewed 732 times since Wed, Feb 6, 2019
Linux 20 Netstat Commands for Linux Network Management
Viewed 461 times since Mon, Sep 21, 2020
A Simple Guide to Oracle Cluster File System (OCFS2) using iSCSI on Oracle Cloud Infrastructure
Viewed 1781 times since Sat, Jun 2, 2018
Install OpenVPN On CentOS / RHEL 7
Viewed 733 times since Fri, May 15, 2020
RHEL: Scan and configure new SAN (fibre channel) LUNs
Viewed 4922 times since Sun, May 27, 2018
RHCS: Configure an active/backup pacemaker cluster
Viewed 1875 times since Sun, Jun 3, 2018
Linux Network (TCP) Performance Tuning with Sysctl
Viewed 5543 times since Fri, Aug 3, 2018
RHEL: Route network packets to go out via the same interface they came in
Viewed 1502 times since Sat, Jun 2, 2018
Using renice and taskset to manage process priority and CPU affinity with Linux OEL 6.4
Viewed 886 times since Mon, Feb 17, 2020