How to reset root Password Ubuntu & Fedora

Lost your root password? 

If you have lost your root password, you can't really recover it, but you can change it if you have physical access to the machine. 

The two most used methods of changing your root password if it's lost is: 
	Booting into single-user mode and resetting the password 
	Booting from a live CD and gain access to your installed system 

Changing your root password by booting into single user mode: 
	Step 1: Reset your computer 
	Step 2: Boot into single user mode 

Note: This will not work on high-security systems where GRUB or LILO is password protected. (You could use a bootable GRUB floppy to do this, though - and can anyone say "backdoor BIOS passwords" ;-) 

Note: On debian-like systems, even single user mode prompts for a root password - see the Debian variations section below. 
Booting into single user mode depends on the boot manager you're using. 

To boot into single user mode using GRUB: 

	1. You might have to press <ESC> to see your boot menu (you will see a prompt)
	2. Choose the kernel you want to boot using the arrow buttons on your keyboard
	3. Press "e" for edit
	4. Press the "end" button on your keyboard, type in a comma space ", " and then type "single"
	5. Press <ENTER> and than "b" to boot that kernel, this will take you into single user mode

To boot into single user mode using LILO: 
	1. You might have to hold in the "shift" key to see the lilo: prompt (depending on your setup)
	2. Type your kernel name, followed by "1" (for runlevel 1), a typical example would be:
    lilo: linux 1

Step 3: Change your root password 

Once you get to the command line prompt, type: 

# passwd

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

You can then reboot and use your new root password 

Debian variations 

Instead of adding " single" or " 1" to your kernel command line, add " init=/bin/bash" 
When it boots up, mount your root filesystem read-write: 

# mount / -o remount,rw

Change the password: 

# passwd

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Unmount and reboot 
# mount / -o remount,ro
# sync
# reboot

Changing your root password from bootable media 
    Step 1: Boot into another Linux system 
This can be any other Linux system on your computer. It can be another installed distribution, or a live CD such as RIP (Recovery is Possible) or Knoppix. 
   
    Step 2: Open a terminal 
If you have booted into a system such as Knoppix or the Ubuntu Live CD, you will need to open a terminal first. Alternatively, you can switch to a virtual terminal by pressing CTRL+ALT+F2. You will need root access on this system to gain access to your system. 

    Step 3: Mount your root filesystem to be rescued 
This will be the filesystem that contains your /bin, /etc and /sbin directories, typically /dev/sda1 or /dev/hda1. 
Typing the following can give you a list of partitions with sizes, this might give you a clue as to which partition your root partition is: 

#cat /proc/partitions

To mount your root partition, type: 
#mount /dev/hda1 /mnt

To gain access to your system, type: 
#chroot /mnt

You will now have full access to your old system. To change your root password, type: 
# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

To exit from the chroot, type 'exit'. You can now reboot (by typing 'reboot' and to press enter') and gain root access to your system again. 
Changing the root password with sudo 

If you are using a system like Ubuntu, where the first user installed has sudo rights, or if you have sudo configured for one of your users, then you can change your root password using sudo: 
govath@ubuntu$ sudo passwd root
Password:
(enter your user password here, not root's) 
Enter new UNIX password:
(enter and re-enter your new root password here) 
-----------------------------------------------------

Knoppix Method
http://www.howtoforge.com/how-to-reset-a-forgotten-root-password-with-knoppix



 

 

 

 

About these ads

About govath

My name is Alexadros Theofilou im working as an Linux/Windows Administrator in Cyprus.

2 responses to “How to reset root Password Ubuntu & Fedora”

  1. AndreyV says :

    Wow, that’s a long post,mate! :)

    Just for summarizing:
    1. Boot
    2. Get to kernel menu
    3. Choose the kernel version you’re using
    4. Choose initz-blah-blah and press “e”
    5. Insert “1″ at the end, press “enter”, press “b”
    6. After the restart you’re under root. Print “passwd”, do the password thingy, and restart.

    Shorter ? ;)

    P.S.: Welcome back to blogosphere ;P

  2. govath says :

    Haha yes in deed .

    I try to reset my password and i did it completely different :P
    Boot: press ‘e’
    Linux init=/bin/sh

    # mount -n -o remount,rw /
    # vi /etc/passwd

    and i removed the x . is like this = : x :
    save it and
    passwd new password :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: