I have this tendency of playing around with software in virtual machine first before exposing it to my production environment. There are lots of reasons for doing so, checking compatibility, worthiness, dependency requirements, and what not. Its always a safe bet to install and run a package in test machine (in this case a Virtual Machine) before pushing in to your actual machine.
This also means that there are times when I don’t power on the virtual machine for weeks at all and hence suffer the possibility of losing track of its credentials, including password for its user account. Although, I do make a point of storing the password in some form at some place but there’s always a chance of things going wrong.
Something similar happened last week, when I booted into a Ubuntu 16.04 virtual machine to play around with CrossOver linux and Play On Linux, just to see if Microsoft Office 2010 or 2013 do, in-fact, work. That’s when I realized I forgot password for the machine! Changing the forgotten or rather lost password was quite simple.
All I had to do was to shutdown the machine. Boot it back and just after pressing the “Start up this guest operating system”, start pressing the Shift key continuously. The reason for frantically hitting the Shift key is that in VMware Workstation, the boot screen appears for a very very short duration, giving your almost no time to get into it. So, don’t be surprised if the Shift key isn’t registered the first time.
Once you get into the boot manager, follow the below mentioned steps,
3Click on “Advanced options for Ubuntu”
2Choose recovery mode for any one of the available kernels
1Under Recovery Menu, choose root
You’ll then be asked to press Enter key for entering maintenance. Press the Enter key (duh!).
Thereafter, you will have the terminal at your disposal with root privileges. Go bonkers! No, wait. Not yet. First, mount the root (/) file system as read-write by typing in (no need for sudo),
mount -rw -o remount /
Once this is done, issue following command to reset password for the user (replace user_name with your username),
That’s about it. The system will ask for new password and once done, exit the terminal by typing,
and continue with boot process, you’ll have reset your lost password successfully!
Note – Mileage may wary for Virtualbox as compared to VMware Workstation.