how could one login to the fedora 15 if he/she has forgot the password of both root and user
Boot with a live cd/dvd/usb drive, mount the root file system on the hard drive to some local mount point such as /mnt/sysroot (you will have to create the directory first), then you can, as root in the live system, edit the /etc/shadow file to remove the password for the user account, then edit the /etc/sudoers file to allow that user to sudo to root. Reboot to the hard drive, login as the user, sudo su - to get to root, and then change root's password.
I know, your eyes are rolling around the back of your head about now, right? :-) So, here are the steps above in a list:
- Boot from a live cd/dvd/usb drive
- Login to the system as root
- Create a mount point for the system drive: mkdir /mnt/sysroot
- Mount the system root file system on the new mount point. For Red Hat / Fedora systems, this is usually /dev/sda3, but it may not be. You can see what the system partitions are with the command "fdisk -l /dev/sda". Assuming it is /dev/sda3, do this: mount /dev/sda3 /mnt/sysroot
- Edit /mnt/sysroot/etc/shadow with vi and find the user account. If the user's name is jones, then find the line that starts with "jones:" and delete the long bit of gobledygook that follows up to the next colon ':', leaving the rest of the line alone.
- Save the file and exit vi.
- Edit /mnt/sysroot/etc/sudoers and add this line (assuming that 'jones' is the user account): jones ALL=(ALL) NOPASSWD: ALL
- Save and quit from the sudoers file.
- Reboot the system from the hard drive.
- Login as the user (jones).
- Open a console window.
- Switch to root with the command: sudo su -
- As root, run the passwd command and change the root account's password to something you want.
- Exit from root back to jones.
- Change jones' password also with the passwd command.
- Logout and see if you can log back in as root or jones using the appropriate passwords.
All of this proves one thing, that if you have physical access to a system, and it is not using some sort of full-disc encryption, you can do anything you want. :-)
I'm only noob-intermediate when it comes to linux but wouln't you also need to go back into the /etc/sudoers and change jones to
jones ALL=(ALL) ALL
so that jones cannot just login to root with out a password?
After you have changed both the root and user (jones) passwords of course.
Another simpler solution that doesn't involve a live CD and all this fiddling with the system files is to simply boot into single-user mode. I had this happen to be a couple of times, grabbing a dusty old Linux box that noone had the password for, booting into single-user mode and just resetting the password with passwd command takes about 5 minutes at most.
Edited by mike_2000_17