When you install or reinstall a distribution or operating system, a root access password is provided. It’s recommended to change it to secure your Dedicated Server. You may also find that you have lost this password, or need to change it.
To change the password after you lost it:
- Firstly, put your server into rescue mode.
- Then, identify the system partition with the following command:
Disk /dev/hda 40.0 GB, 40020664320 bytes 255 heads, 63 sectors/track, 4865 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 1305 10482381 83 Linux /dev/hda2 1306 4800 28073587+ 83 Linux /dev/hda3 4801 4865 522112+ 82 Linux swap / Solaris Disk /dev/sda 8254 MB, 8254390272 bytes 16 heads, 32 sectors/track, 31488 cylinders Units = cylinders of 512 * 512 = 262144 bytes Device Boot Start End Blocks Id System /dev/sda1 1 31488 8060912 c W95 FAT32 (LBA)
In the example above, the system partition is /dev/hda1.
- Next, mount the system partition using the following commands:
# mount /dev/hda1 /mnt/
- By default, the system partition is locked for editing. You need to enable it to write access:
# chroot /mnt
- Lastly, change the password:
# passwd Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
When this is done, change the boot mode on your server back toboot from hard disk
and restart it. Your root password is successfully changed.