Wednesday, February 25, 2015

Reset root Password in Centos 7/Fedora Server 21

Its mandatory to setup password for root account in Linux. Sometimes, we don't remember passowrd and somehow lose. There are the procedures for breaking it or you can say reset this to new one.

Below is the step by step process for achieving the target  :
  • Boot up your Fedora system, during bootsplash/bootscreen press arrow keys which will show you grub boot screen as below:
  • Press "e" to enter into edit mode as below:
  • After this scroll down to line starting with "linux16" and add "rw init=/bin/bash" at the end of line. Now what these parameter do is :
      1. rw : With this option kernel will mount the root File System in Read-Write mode.
      2. init=/bin/bash : In Linux/Unix based systems init is the first process which gets started during booting. Here we are asking to start bash shell instead of normal system initialization scripts.

  • Now boot System using "Ctrl-x" as mentioned in screen as well and it will take you to bash shell with root file system mounted in read-write mode.


  • After that verify the mounted root file system, reset your root password.
root file system mounted without "rw" option
root File System mounted with "rw" option
  • Create .autorelabel file in root(/) file system to relabel SeLinux Policy as changing password will change the other files as well e.g. shadow. Another thing you need to reboot server forcefully otherwise it will not be able to communicate with init daemon for reboot. SO, make sure to use "-f" switch during reboot. If reboot doesn't work, then try with "exec /sbin/init" command.  Finally reboot the server and test your new password.

  • Login to System and check when your password have been changed :).

Enjoy!!

No comments:

Post a Comment

Kubernetes 1.31 || Testing the Image Volume mount feature using Minikube

With Kubernetes new version 1.31 ( https://kubernetes.io/blog/2024/08/13/kubernetes-v1-31-release/ ) there are so many features releases for...