{"id":14823,"date":"2023-05-10T11:22:19","date_gmt":"2023-05-10T10:22:19","guid":{"rendered":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?p=14823"},"modified":"2023-05-10T11:22:22","modified_gmt":"2023-05-10T10:22:22","slug":"how-to-reset-the-root-password-in-centos-rhel7","status":"publish","type":"post","link":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/","title":{"rendered":"How to Reset the Root Password in CentOS\/RHEL7?"},"content":{"rendered":"\n<p>Generally, it&#8217;s an easy way to reset the root password if you&#8217;re already logged in with the root privileges. However, if you forget the password and need to change it, here&#8217;s an article for you.<\/p>\n\n\n\n<p>To reset the root password on CentOS7\/RHEL 7, you need:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>A working GRUB root loader<\/li><li>A working operating system<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Reset Root Password on CentOS 7\/RHEL 7<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Method 1: Rebooting and Editing Grub2<\/h2>\n\n\n\n<p>Reboot the system and press any key to auto-boot from the default kernel. Then, press &#8220;e&#8221; after selecting the kernel line to enter the Grub Edit Mode<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode.png\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"83\" src=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode.png\" alt=\"grub edit mode\" class=\"wp-image-14824\" srcset=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode.png 602w, https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode-300x41.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/a><\/figure>\n\n\n\n<p>After you press the &#8220;e&#8221; key, scroll down, go to the Linux 16 line, and remove the rhgb, quiet and LANG parameters.<\/p>\n\n\n\n<p>For moving at the end of the line, press ctrl+e, move to the front, and press ctrl+a.<\/p>\n\n\n\n<p>The Linux16 line will be linuxefi on the UEFI system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method 2: Appending the rd.break to kernel<\/h2>\n\n\n\n<p>When you are in edit mode, go to the line starting with linux16 and append rd.break at the end of this line.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/rd-break-to-kernel.png\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"83\" src=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/rd-break-to-kernel.png\" alt=\"\" class=\"wp-image-14825\" srcset=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/rd-break-to-kernel.png 602w, https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/rd-break-to-kernel-300x41.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/a><\/figure>\n\n\n\n<p>This will make the machine boot into emergency mode, giving you root user privileges without entering a root user password. Even though the root user hasn&#8217;t been set, this still works.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reboot the System<\/h3>\n\n\n\n<p>Press CLTR+x after appending the rd.break to the kernel. This will help to reboot the system into emergency mode.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/system-reboot.png\"><img loading=\"lazy\" decoding=\"async\" width=\"578\" height=\"151\" src=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/system-reboot.png\" alt=\"system reboot\" class=\"wp-image-14826\" srcset=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/system-reboot.png 578w, https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/system-reboot-300x78.png 300w\" sizes=\"auto, (max-width: 578px) 100vw, 578px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Remounting the sysroot<\/h3>\n\n\n\n<p>Firstly, we will remount the sysroot file system in read-write mode and then use the chroot to get into a chroot jail.<\/p>\n\n\n\n<p># mount -o remount, rw\/sysroot<\/p>\n\n\n\n<p># chroot \/sysroot<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Resetting the Root Password<\/h3>\n\n\n\n<p>Type a password command in the command line and set the new password for the root user. You might even get into some warnings like &#8220;password fails directory check&#8221; if your password is weak. You can ignore the warning and set the password you want.<\/p>\n\n\n\n<p># passwd<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/resetting-root-password.png\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"120\" src=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/resetting-root-password.png\" alt=\"\" class=\"wp-image-14827\" srcset=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/resetting-root-password.png 602w, https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/resetting-root-password-300x60.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">SElinux relabeling<\/h3>\n\n\n\n<p>All the unlabeled files, which include the shadow files, get relabelled during the booting. The hidden files auto-relabel the files changed outside their regular context, like the file\/etc\/shadow.<\/p>\n\n\n\n<p># touch \/.autorelabel<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sync<\/h3>\n\n\n\n<p>If you want to flush the cache of the disk, type the command given below:<\/p>\n\n\n\n<p># sync<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reboot<\/h3>\n\n\n\n<p>Type the exit command twice and leave the chroot environment and log out. The system will apply some SELinux contexts and reboots.<\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>By following the steps given above, you can easily login to CentOS\/RHEL using the new password.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Generally, it&#8217;s an easy way to reset the root password if you&#8217;re already logged in with the root privileges. However, if you forget the password and need to change it, here&#8217;s an article for you. To reset the root password on CentOS7\/RHEL 7, you need: A working GRUB root loader A working operating system Steps [&hellip;]<\/p>\n","protected":false},"author":34,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[2965],"class_list":["post-14823","post","type-post","status-publish","format-standard","placeholder-for-hentry","category-howtos","tag-rehl7"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Reset the Root Password in CentOS\/RHEL7? | MilesWeb<\/title>\n<meta name=\"description\" content=\"If you forget the root password in CentOS\/REHL7, you can reset it easily. This article explains the steps to reset the root password in CentOS\/REHL7.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Reset the Root Password in CentOS\/RHEL7? | MilesWeb\" \/>\n<meta property=\"og:description\" content=\"If you forget the root password in CentOS\/REHL7, you can reset it easily. This article explains the steps to reset the root password in CentOS\/REHL7.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Hosting FAQs by MilesWeb\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-10T10:22:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-10T10:22:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode.png\" \/>\n<meta name=\"author\" content=\"Nehal Khatri\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nehal Khatri\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/\",\"name\":\"How to Reset the Root Password in CentOS\/RHEL7? | MilesWeb\",\"isPartOf\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode.png\",\"datePublished\":\"2023-05-10T10:22:19+00:00\",\"dateModified\":\"2023-05-10T10:22:22+00:00\",\"author\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/0241ea191f60975839d956b6952e0a1d\"},\"description\":\"If you forget the root password in CentOS\/REHL7, you can reset it easily. This article explains the steps to reset the root password in CentOS\/REHL7.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/#primaryimage\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode.png\",\"contentUrl\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode.png\",\"width\":602,\"height\":83,\"caption\":\"grub edit mode\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Reset the Root Password in CentOS\/RHEL7?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/\",\"name\":\"Web Hosting FAQs by MilesWeb\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/0241ea191f60975839d956b6952e0a1d\",\"name\":\"Nehal Khatri\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/736396ef8d8bdecec53ce8851058903e?s=96&d=blank&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/736396ef8d8bdecec53ce8851058903e?s=96&d=blank&r=g\",\"caption\":\"Nehal Khatri\"},\"description\":\"Nehal is an ardent content writer. She's passionate about crafting content that's simple but adds value. Her insatiable interest in writing has allowed her to explore her skills. She is adept and can write for different types of content formats.\",\"url\":\"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/nehal-khatri\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Reset the Root Password in CentOS\/RHEL7? | MilesWeb","description":"If you forget the root password in CentOS\/REHL7, you can reset it easily. This article explains the steps to reset the root password in CentOS\/REHL7.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/","og_locale":"en_GB","og_type":"article","og_title":"How to Reset the Root Password in CentOS\/RHEL7? | MilesWeb","og_description":"If you forget the root password in CentOS\/REHL7, you can reset it easily. This article explains the steps to reset the root password in CentOS\/REHL7.","og_url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/","og_site_name":"Web Hosting FAQs by MilesWeb","article_published_time":"2023-05-10T10:22:19+00:00","article_modified_time":"2023-05-10T10:22:22+00:00","og_image":[{"url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode.png","type":"","width":"","height":""}],"author":"Nehal Khatri","twitter_misc":{"Written by":"Nehal Khatri","Estimated reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/","name":"How to Reset the Root Password in CentOS\/RHEL7? | MilesWeb","isPartOf":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/#primaryimage"},"image":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/#primaryimage"},"thumbnailUrl":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode.png","datePublished":"2023-05-10T10:22:19+00:00","dateModified":"2023-05-10T10:22:22+00:00","author":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/0241ea191f60975839d956b6952e0a1d"},"description":"If you forget the root password in CentOS\/REHL7, you can reset it easily. This article explains the steps to reset the root password in CentOS\/REHL7.","breadcrumb":{"@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/#primaryimage","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode.png","contentUrl":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-content\/uploads\/2023\/05\/grub-edit-mode.png","width":602,"height":83,"caption":"grub edit mode"},{"@type":"BreadcrumbList","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/how-to-reset-the-root-password-in-centos-rhel7\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/"},{"@type":"ListItem","position":2,"name":"How to Reset the Root Password in CentOS\/RHEL7?"}]},{"@type":"WebSite","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#website","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/","name":"Web Hosting FAQs by MilesWeb","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/0241ea191f60975839d956b6952e0a1d","name":"Nehal Khatri","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/736396ef8d8bdecec53ce8851058903e?s=96&d=blank&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/736396ef8d8bdecec53ce8851058903e?s=96&d=blank&r=g","caption":"Nehal Khatri"},"description":"Nehal is an ardent content writer. She's passionate about crafting content that's simple but adds value. Her insatiable interest in writing has allowed her to explore her skills. She is adept and can write for different types of content formats.","url":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/author\/nehal-khatri\/"}]}},"views":86,"_links":{"self":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/14823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/comments?post=14823"}],"version-history":[{"count":1,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/14823\/revisions"}],"predecessor-version":[{"id":14828,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/posts\/14823\/revisions\/14828"}],"wp:attachment":[{"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/media?parent=14823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/categories?post=14823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.milesweb.co.uk\/hosting-faqs\/wp-json\/wp\/v2\/tags?post=14823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}