Reset root password linux

Originally posted on phunkymunkys.com on 10/01/2012. Original Article


This will work for all users although if you know the root password you can reset the user password anyway.

So I was going to use my old PC as a client for my Windows Domain Admin class but first I needed to make sure that I didn’t have any files that were important, unlikely since I hadn’t used the computer in years, but still need to check.

So I booted up the old PC and realised I couldn’t remember the passwords, oops!! After googling for the answer I found this way to reset (really delete) the root password, well any user password since they are all in the same file. BTW this computer is running Slackware Linux 12.2 (probably my favourite Slackware release)

Get a bootable distro that you can copy to disk and boot into a live environment or use one of the many rescue disks out there, I used SystemRescueCD which is really nice and easy to use and is quite easy on resources, the PC only has 640Mb of memory, so the newer Ubuntu live CD doesn’t run very fast or smooth.

Boot up the CD select an option, there are quite a few, I had to try a couple before I got one that worked, seems that there was a problem booting into a graphical environment, something wrong with the monitor settings (out of sync or refresh error, I forget which) but that doesn’t matter since I am happy using the command line. So once booted and at the prompt you need to mount the physical hard disk (remember this is running off the disk/RAM);

1
mount -t auto /dev/sda1 /mnt

Then go to the /etc directory

1
cd /mnt/temp/etc/

Edit the shadow file that holds the password information using your favourite editor such as emacs, vi, pico etc, my editor of choice is emacs

1
emacs shadow

What you need to do is locate the line that starts with root, usually the first line, and remove the encrypted password. This is the random assortment of letters between the second and third colons (:), highlighted in red below and just delete it.

root:$1$VvdL6/uZ$iQV835Rh7tgvpi2akemVt.:15080:0:::::

This leaves

root::15080:0:::::

Save the file and that’s it, just reboot, remembering to remove the CD and when you get to the login screen* just enter root as username and leave the password field empty and BOOM!! access is granted (see note below)

Last thing…remember to set a new root password.

* I couldn’t login through the GUI after I had done this I had to reboot using the liveCD and change the runlevel in the inittab file then reboot to the text login and all was well, gave myself a new password and changed the runlevel back to the GUI and rebooted and was able to login as needed.

Adding Serial Port support to Virtualbox

This post was originally posted on phunkymunkys.com on 22/09/2011  link to original post

Having got hold of a Cisco router I had to try to connect to it via my Windows XP virtual machine installed in VirtualBox. The problem I had was the COM port was not recognised in the VirtualBox settings, every time I tried to start the Windows VM it failed with an error.  One of these errors suggested checking the permissions and user groups to make sure these were correct.
Turns out I needed to add my (host) user to the correct group.

Use the command

1
ls -l /dev/ttyS*

to list the current groups for tty’s.
Output of tty configuration

As can be seen here the serial ports are all in the dialout group so using the user manager I added myself to the dialout group. Once that was done ( remember to logout and back in once you change group associations!! ) I set up the serial port in the virtualbox settings COM1, choose the Host Device option and add /dev/ttyS0 as the path.

Serial port configuration VirtualBox

Once this was done I started the Windows XP virtual machine and it now booted fine and once logged in Windows detected the new hardware and installed it automatically.

Now I am able to console into the router and all is good.