Youcan boot a different installation (e.g. from DVD), mount the partition with /etc/shadow and clear the password (set it to the empty string). You can also try to run a password cracker on the file if you really need to know what it was.
Fastest way is to pass the parameter init=/bin/bash to the boot loader (see an example here). That would give you a root console pretty much immediately, now mount -a and mount -o remount,rw / to get access to the system. Finally, a passwd command should allow you to set the root password.
Second option (since nowadays linux distro need a ramdisk with drivers when they start) is to boot with a live distro, then mount your linux partition somewhere (a-la mount /dev/sda1 /mnt), mount also /proc and /dev (devfs usually) into the new partition (mount --bind /proc /mnt/proc and mount --bind /dev /mnt/dev). Finally, chroot /mnt and mount -a should give you your system back. Now, sometimes live distro see your hard disk as sd (the old SCSI mapper, now used for SATA disks), so you might end up with /dev/hda mapped to /dev/sda. That were the case you need to mount by hand all that you find in your /mnt/etc/fstab file. Once that's done you can try the chroot again, and then passwd.
Have you ever forgotten your root password and needed to reset it? I have a very good memory. I remember most of my client'spasswords (there are a few I forget regularly for no reason that Ican understand, but I really do know most), I remember telephonenumbers, and of course I know my own passwords. That last isn't aseasy as it might sound, because I have quite a few differentsystems and each has its own password, but though I might use thewrong one now and then, I'll get it on the second or third try.
Well, not this time. A while back I installed Fedora on asystem here, and today I wanted to look at something and .. whatwas the root password? Hmm, not that.. how about? .. nope, well itmust be.. darn!
Twice I have been at customer sites with a lost root paswordand found that root was already logged in on one of the Alt screens. It is worth checking.. check "w" too. It's a long shot,but somebody might be in a long forgotten window.
But let's try it the easy way first. The next thing to try is to boot to single user mode. This MIGHT not work for you, because your system might be configured to still ask for a root password to get to single user mode. If that's the case, we'll use another trick that replaces init with /bin/bash.
If you don't see either a LILO or GRUB boot screen, try hitting CTRL-X to get one. Once you have that, if it's LILO, just type "linux single" and that should do it (assuming that "linux" is the lilo label, which it probably is). If GRUB, hit 'e", then select the "kernel" line, hit "e" again, and add " single" (or just " 1") to the end of the line. Press ENTER, and then "b" to boot. (More modern grub uses "a" to append to the boot line)
You should get a fairly normal looking boot sequence except that it terminates a little early at a bash prompt. If you get a "Give root password for system maintenance", this isn't going to work, so try the "init" version below.
Another trick is to add "init=/bin/bash" (LILO "linux init=/bin/bash" or add it to the Grub "kernel" line). This will dump you to a bash prompt much earlier than single user mode, and a lot less has been initialized, mounted, etc. Note that other filesystems aren't mounted at all, so you may need to mount them manually if you need them. Look in /etc/fstab for the device names or use "fdisk -l" to list available partitions.
However, some systems are protected with boot loader passwords that won't let you do that without THAT password. If the boot loader is password protected, you need to boot from other media - for newer systems, the install CD probably has the recovery tools for that ("linux rescue" for example). You could use your install disks or download something like Tom's Root and Boot Disk.
If using something like "linux rescue" or other boot media, if the recovery disk doesn't automatically mount your disk, you need to do it manually. This shouldn't be difficult unless you have an unusual disk controller. For example, a Compaq raid controller will probably be /dev/ida/c0d0. Find the partitions by using fdisk /dev/ida/c0d0 (just "p" and quit) and then mount what you need.
You might "mount /dev/hda2 /mnt". Once you have your filesystem mounted, you might try "chroot" and then use "passwd" to fix things up. Say you have the old drive at "/mnt" - type "chroot /mnt" and then use "passwd".
Or just edit /mnt/etc/shadow to remove the password field: move to just beyond the first ":" and remove everything up to the next ":". With vi, that would be "/:" to move to the first ":", space bar once, then "d/:" and ENTER. You'll get a warning about changing a read-only file; that's normal. Before you do this, /mnt/etc/shadow might look like:
You'll need to force the write: with vi, ":wq!". (If that stilldoesn't work, you needed to do the -o remount,rw, see above). If it does work, you have reset root to not have a password. You'll want to change that soon, of course.
Keep this in mind if you have a Linux machine in a publically accessible place : without more protection, it's not usually hard to recover a lost root password, which means it's just as easy for someone to CHANGE it, or access root without your knowlege. The only difference between "break root" and this is intent. Hacking root's password can be accomplished with these same methods, so if you want to protect your machine, you may want to close these off.
actually i have gone through a problematic situation ,where esm admin password got expired ,and i have to reset the password through linux console ,so could you guide me ,the steps how to reset the ESM admin password through linux console.
This article provides three methods to reset local Linux Virtual Machine (VM) passwords. If the user account is expired or you want to create a new account, you can use the following methods to create a new local admin account and regain access to the VM.
If SElinux is in enforcing mode, make sure that SElinux allows the file changes made with the passwd command. After the password is changed, you can run the following command to relabel the file system to facilitate the loading of the alteration.
If you're experiencing problems that affect an Azure network virtual appliance, this method doesn't apply to your situation. Instead, you must contact the vendor of the network virtual appliance to get instructions about how to do a password reset safely.
You can run the vm repair commands to create a repair VM that has a copy of the affected VM's OS disk attached. Then, mount the copy of the OS file systems on the repair VM via the chroot environment.
I tried with Developer Studio Legato recovery wizard. After success flashing, I can not enter via SSH, password is required and the blank passwd is not good for it. As I remember blank pw is the default for root.
THX
Tom
Hi @tomx,
I think you can reset the password using the swiflash linux tool. You can use the below command which will restore the Linux root filesystem in its original state by erasing the USER1 partition and your password will be reset.
@tomx,
That is the reason i told to use the swiflash tool to reset the paswword with command i have provided. swiflash is the host tool, you have to connect your board with the Wp7702 module to host PC and execute the command i have provided from the host PC.
3a8082e126