SlideShare a Scribd company logo
 
   
Resetting Lost root Password in RHEL7 & CentOS7 
In this howto you will learn the process of resetting the lost root password in 
RHEL7 & CentOS7 
In this password recovery process you should pass the ​rd.break​ parameter 
as a kernel argument at the​ ​Stage2​ ​menu of ​GRUB2​ boot loader which is the 
default boot loader of RHEL7 & CentOS7 systems.  The documents was 
created using RHEL7 VM which was running on a KVM hypervisor.  
Reboot your ​Linux system​ ​ and when it display the following ​GRUB2 Stage2
menu​ ​screen press ​ESC​ ​key and then type letter ​“e”​ to edit the menu entries. 
Look at the red box in this screen beloe. You have to be ultra quick here as it 
passes this screen in just ​5​ seconds. 
 
Then you will see the following screen. The ​linux16​ ​grub command is our 
concern here as ​GRUB​ is using this command to load the kernel and to pass the 
parameters required by the kernel at this stage.  
 
1 | Page 
 
Delete all the additional parameters which is marked using a red color polyline 
as shown in the above screen upto ​ro (read-only)​ ​parameter which is used 
to mount your system's root (/)  filesystem read only at this stage. The end 
result should look like below. 
 
Next you need to type​ ​rd.break​ parameter after the above ​ro​ parameter and 
the end result should look like the screen below. 
2 | Page 
 
Next press the ​Ctrl+x​ key sequence to continue the boot process further.  
The ​rd.break​ parameter instructs the Kernel  to break the boot process 
before it passes the control to the ​systemd​ master process and break the boot 
process after mounting initial ramdisk ​(​initrd​)​ as Linux ​/​ ​filesystem. At this 
stage you can recover the lost ​root password​ and carry out  other 
troubleshooting tasks if required. 
The system will show the following screen. At the command line type ​mount 
command to view mounted file systems at this stage.  
 
Observe the  red color box below in the screen below. You will observe that 
your system’s ​root (/)​ ​file system on ​/dev/vda1​ ​has been mounted on 
/sysroot​ ​in read-only ​(​ro​)​ mode. The​ ​/sysroot​ mount point is a directory 
in  the ramdisk which is currently being used as ​/​ filesystem.  
3 | Page 
 
Before we further proceed we need to remount​ ​/sysroot​ ​in read-write ​(​rw​) 
mode so that we can write our modification to the disks. Observe the screen 
below. 
 
As demonstrated in the red box of the above screen execute the command to 
remount​ ​/sysroot​ in ​rw​ mode. 
# mount -o remount,rw /sysroot
# mount | grep sysroot
Executing ​mount | grep sysroot​ ​command you can verify  that ​/sysroot​ is 
now mounted in ​rw​ mode.  
Observe the next screen to find out how to change your root password as 
“Postroll”​. ​This command changes the root password non-interactively​.
# echo Postroll | passwd --stdin root.
4 | Page 
 
It is important to check whether your ​root​ user has expired. You can observe 
the following screen to understand this process.  
This is optional, but it will be useful to know how to activate an expired root 
account.  You do not require the following steps if the root account haven’t set 
to expire.  
 
Observe the above screen to understand that the ​root​ account has been 
expired on ​1​st​
January 1970​.  You can run the following command to reset 
the expiry date for the root account.  
# chage -E -1 root
To learn more about the syntax of the above command use​ ​man chage
command and search for option ​-E​.
Observe the following screen to find whether you have reset ​root​ account 
expiry properly. 
5 | Page 
 
Run ​chage -l root​ command as shown in the above screen and you will 
observe that Account expiration set to ​never​ which is the default setting for 
the ​root​ user account. 
In this ramdisk environment SELinux in ​disabled​ mode. Observe the screen 
below.  
 
As shown in the above screen run ​getenforce​ command and you will 
observe that SELinux in ​Disabled​ mode.  
Running ​ls -Z /etc/shadow​ ​command as shown in the above screen you 
have observed that there is no SELinux label for this file. 
Running  ​cat /etc/sysconfig/selinux​ ​command above you have observed 
that SELinux will be in ​enforcing​ ​mode when the system is running at next 
reboot. This requires a relabeling of the filesystem at next reboot. This can be 
achieved by creating a blank file named ​.autorelabel​ ​in​ ​/​ ​directory. Run 
the following command. 
6 | Page 
# ​touch /.autorelabel
Then type the following command to exit from the chroot environment. 
# ​exit
Execute the exit command again to reboot the system. 
# ​exit
Observe the following screen. 
 
Observe the red box in the screen below. You will see that the system is 
re-labeling. The time taken for this process will depend on the number of files 
and directories in your system. 
 
Once the labeling is over the system will reboot again and  you should be able 
to successfully login to root account with the password ​“​Postroll​”.
Author: Chinthaka Deshapriya (RHCA). 
Last modified:  20​th​
 May, 2017.  
Inquires: +94-766-783-783 and 
7 | Page 
 
8 | Page 

More Related Content

Similar to Rhel7 cent os7-reset-root-password-v1

Grub2 and troubleshooting_ol7_boot_problems
Grub2 and troubleshooting_ol7_boot_problemsGrub2 and troubleshooting_ol7_boot_problems
Grub2 and troubleshooting_ol7_boot_problems
Tommy Lee
 
Oracle e business-suite_r12_installation_guide_step_by_step_on_linux
Oracle e business-suite_r12_installation_guide_step_by_step_on_linuxOracle e business-suite_r12_installation_guide_step_by_step_on_linux
Oracle e business-suite_r12_installation_guide_step_by_step_on_linux
moh_arifay
 
Linux Booting Process
Linux Booting ProcessLinux Booting Process
Linux Booting Process
Rishabh5121993
 
Intro xp linux
Intro xp linuxIntro xp linux
Intro xp linux
kalaisundaram
 
Testps
TestpsTestps
lec4.docx
lec4.docxlec4.docx
lec4.docx
ismailaboshatra
 
2- System Initialization in Red Hat
2- System Initialization in Red Hat2- System Initialization in Red Hat
2- System Initialization in Red Hat
Shafaan Khaliq Bhatti
 
Lab: Installation of Xilkernel on Xilinx Spartan 3E Starter board
Lab: Installation of Xilkernel on Xilinx Spartan 3E Starter boardLab: Installation of Xilkernel on Xilinx Spartan 3E Starter board
Lab: Installation of Xilkernel on Xilinx Spartan 3E Starter board
Vincent Claes
 
Important cisco-chow-commands
Important cisco-chow-commandsImportant cisco-chow-commands
Important cisco-chow-commands
ssusere31b5c
 
How to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by IvanHow to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by Ivan
Ivan Silva
 
Linux boot process – explained
Linux boot process – explainedLinux boot process – explained
Linux boot process – explained
LinuxConcept
 
Password Recovery
Password RecoveryPassword Recovery
Password Recovery
NetProtocol Xpert
 
2009 reborn card plus version
2009 reborn card plus version 2009 reborn card plus version
2009 reborn card plus version
cordobaboxeador
 
9adcab7c 1 crash
9adcab7c 1 crash9adcab7c 1 crash
9adcab7c 1 crash
PrezMan3141
 
Adding System Call to Kernel
Adding System Call to KernelAdding System Call to Kernel
Adding System Call to Kernel
Muhammad Bilal
 
101 1.2 boot the system
101 1.2 boot the system101 1.2 boot the system
101 1.2 boot the system
Acácio Oliveira
 
101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot
Acácio Oliveira
 
Linux
LinuxLinux
OS_lab_file.pdf
OS_lab_file.pdfOS_lab_file.pdf
OS_lab_file.pdf
KarthickS942388
 
lab1
lab1lab1

Similar to Rhel7 cent os7-reset-root-password-v1 (20)

Grub2 and troubleshooting_ol7_boot_problems
Grub2 and troubleshooting_ol7_boot_problemsGrub2 and troubleshooting_ol7_boot_problems
Grub2 and troubleshooting_ol7_boot_problems
 
Oracle e business-suite_r12_installation_guide_step_by_step_on_linux
Oracle e business-suite_r12_installation_guide_step_by_step_on_linuxOracle e business-suite_r12_installation_guide_step_by_step_on_linux
Oracle e business-suite_r12_installation_guide_step_by_step_on_linux
 
Linux Booting Process
Linux Booting ProcessLinux Booting Process
Linux Booting Process
 
Intro xp linux
Intro xp linuxIntro xp linux
Intro xp linux
 
Testps
TestpsTestps
Testps
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
 
2- System Initialization in Red Hat
2- System Initialization in Red Hat2- System Initialization in Red Hat
2- System Initialization in Red Hat
 
Lab: Installation of Xilkernel on Xilinx Spartan 3E Starter board
Lab: Installation of Xilkernel on Xilinx Spartan 3E Starter boardLab: Installation of Xilkernel on Xilinx Spartan 3E Starter board
Lab: Installation of Xilkernel on Xilinx Spartan 3E Starter board
 
Important cisco-chow-commands
Important cisco-chow-commandsImportant cisco-chow-commands
Important cisco-chow-commands
 
How to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by IvanHow to solve misalignment lun netapp on linux servers by Ivan
How to solve misalignment lun netapp on linux servers by Ivan
 
Linux boot process – explained
Linux boot process – explainedLinux boot process – explained
Linux boot process – explained
 
Password Recovery
Password RecoveryPassword Recovery
Password Recovery
 
2009 reborn card plus version
2009 reborn card plus version 2009 reborn card plus version
2009 reborn card plus version
 
9adcab7c 1 crash
9adcab7c 1 crash9adcab7c 1 crash
9adcab7c 1 crash
 
Adding System Call to Kernel
Adding System Call to KernelAdding System Call to Kernel
Adding System Call to Kernel
 
101 1.2 boot the system
101 1.2 boot the system101 1.2 boot the system
101 1.2 boot the system
 
101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot101 1.3 runlevels , shutdown, and reboot
101 1.3 runlevels , shutdown, and reboot
 
Linux
LinuxLinux
Linux
 
OS_lab_file.pdf
OS_lab_file.pdfOS_lab_file.pdf
OS_lab_file.pdf
 
lab1
lab1lab1
lab1
 

Recently uploaded

Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
LucaBarbaro3
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
marufrahmanstratejm
 

Recently uploaded (20)

Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Trusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process MiningTrusted Execution Environment for Decentralized Process Mining
Trusted Execution Environment for Decentralized Process Mining
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Public CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptxPublic CyberSecurity Awareness Presentation 2024.pptx
Public CyberSecurity Awareness Presentation 2024.pptx
 

Rhel7 cent os7-reset-root-password-v1