{"id":9700,"date":"2024-03-20T22:34:52","date_gmt":"2024-03-20T19:34:52","guid":{"rendered":"https:\/\/sunucun.com.tr\/bilgi\/?post_type=dt_articles&#038;p=9700"},"modified":"2026-11-12T01:09:10","modified_gmt":"2026-11-11T22:09:10","slug":"resetting-linux-password-via-grub","status":"publish","type":"post","link":"https:\/\/sunucun.com.tr\/blog\/resetting-linux-password-via-grub\/","title":{"rendered":"GRUB Recovery Modes in Linux: Resetting a Password and Repairing the System"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">GRUB (GRand Unified Bootloader) is the boot loader that loads the operating system on most Linux systems. When a system won&#8217;t boot, a password has been forgotten or an update has left the machine in a bad state, GRUB&#8217;s recovery options let you repair it without reinstalling. In this article we explain how to open the GRUB menu, use Ubuntu recovery mode, reset a password and fix the <code>grub rescue&gt;<\/code> prompt step by step.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"576\" class=\"wp-image-9699\" style=\"width: 613px; height: auto;\" src=\"https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/03\/linux-lts-desteginin-suresini-guncelledi-4-1024x576.jpg\" alt=\"GRUB recovery modes in Linux\" srcset=\"https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/03\/linux-lts-desteginin-suresini-guncelledi-4-1024x576.jpg 1024w, https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/03\/linux-lts-desteginin-suresini-guncelledi-4-300x169.jpg 300w, https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/03\/linux-lts-desteginin-suresini-guncelledi-4-768x432.jpg 768w, https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/03\/linux-lts-desteginin-suresini-guncelledi-4.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">How to Open the GRUB Menu<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On single-OS installations the GRUB menu is often hidden and the system boots straight through. According to the Ubuntu documentation, to show the menu:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>On BIOS systems:<\/strong> Hold down <code>Shift<\/code> while the computer starts, before the Ubuntu logo appears.<\/li>\n<li><strong>On UEFI systems:<\/strong> Press <code>Esc<\/code> (several times if needed) while the firmware loads. Fast boot can leave very little time, so try again if it doesn&#8217;t work the first time.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You can&#8217;t reach the GRUB menu over SSH on a server, because it appears before the operating system and the SSH service start. If you use a <a href=\"https:\/\/sunucun.com.tr\/en\/vps-server\">VPS server<\/a>, restart it from the VNC\/console screen in your provider&#8217;s control panel and open the menu there.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Recovery Environments in GRUB<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">&#8220;GRUB recovery mode&#8221; usually refers to one of three different environments:<\/p>\n\n\n\n<div class=\"snc-table-wrap\"><table>\n<thead><tr><th>Environment<\/th><th>How to open it<\/th><th>What it is for<\/th><\/tr><\/thead>\n<tbody>\n<tr><td>Recovery mode<\/td><td>The &#8220;(recovery mode)&#8221; entry under &#8220;Advanced options&#8221; in the menu<\/td><td>Boots the system with minimal services; offers a root shell, file system check, package repair and more<\/td><\/tr>\n<tr><td>GRUB command line (<code>grub&gt;<\/code>)<\/td><td>Press <code>c<\/code> in the menu; <code>Esc<\/code> returns to the menu<\/td><td>Runs GRUB commands such as listing disks or loading a kernel manually<\/td><\/tr>\n<tr><td>Rescue shell (<code>grub rescue&gt;<\/code>)<\/td><td>Opens by itself when GRUB fails to load its <code>normal<\/code> module<\/td><td>Lets you locate GRUB&#8217;s files with very limited commands and switch to the normal menu<\/td><\/tr>\n<\/tbody><\/table><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Booting Ubuntu Recovery Mode<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Restart the computer or server and open the GRUB menu.<\/li>\n<li>Select <strong>Advanced options for Ubuntu<\/strong>.<\/li>\n<li>Select the kernel entry ending in <strong>(recovery mode)<\/strong> and press <code>Enter<\/code>.<\/li>\n<li>Choose the option you need in the recovery menu. It includes options such as checking the file system (<code>fsck<\/code>), repairing broken packages (<code>dpkg<\/code>), updating GRUB and dropping to a <strong>root<\/strong> shell.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">In the root shell the root partition is mounted read-only. Make it writable first; if you also need other partitions such as <code>\/home<\/code> or <code>\/boot<\/code>, mount them all afterwards:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mount -o remount,rw \/\nmount --all<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Resetting a Linux Password via GRUB<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you have forgotten your user password, you can set a new one from the root shell in recovery mode:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mount -o remount,rw \/\npasswd username\nsync\nreboot<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>username<\/code> with your own user name; if you don&#8217;t remember it, <code>ls \/home<\/code> shows it. <code>passwd<\/code> asks for the new password twice. After the reboot you can log in with the new password.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Distributions without a recovery mode entry use a different method. On RHEL, AlmaLinux and Rocky Linux, for example, the root password is reset from a special environment opened by editing the boot entry; in that case follow the steps in your distribution&#8217;s official documentation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Temporarily Editing a Boot Entry<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Press <code>e<\/code> while an entry is highlighted in the GRUB menu to edit its commands. For example, if a faulty graphics driver stops the system from booting, you can add a kernel parameter to the end of the line that starts with <code>linux<\/code>. According to the GRUB manual, press <code>Ctrl+X<\/code> to boot the edited entry, or <code>Esc<\/code> to discard the changes and return to the menu.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These edits are not permanent; they apply only to that boot. For a permanent change on Ubuntu\/Debian, edit <code>\/etc\/default\/grub<\/code> and run <code>sudo update-grub<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Fix the &#8220;grub rescue&gt;&#8221; Prompt<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you only see a <code>grub rescue&gt;<\/code> prompt, GRUB has failed to load the <code>normal<\/code> module it needs to show the menu. This usually happens after the disk or partition layout changes, the <code>\/boot<\/code> partition is moved or another operating system is installed. For a temporary fix, first check the current settings and disks:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set\nls\nls (hd0,gpt2)\/<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>ls<\/code> command lists disks and partitions. Once you find the partition that contains the <code>\/boot\/grub<\/code> folder (<code>(hd0,gpt2)<\/code> in the example below), point GRUB to it and switch to normal mode:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set prefix=(hd0,gpt2)\/boot\/grub\nset root=(hd0,gpt2)\ninsmod normal\nnormal<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once the system has booted, reinstall GRUB and update its configuration so the problem doesn&#8217;t come back (Ubuntu\/Debian example; change the disk name to match your system):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo grub-install \/dev\/sda\nsudo update-grub<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The GRUB manual notes that on BIOS systems installing GRUB to the whole disk is more robust than installing it to a partition, and that you shouldn&#8217;t assume the first disk in the operating system is the one the firmware boots from.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A Note on Security<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The steps above also show that anyone with physical or console access can reset a password. To limit this, you can add password protection to GRUB (in a password-protected menu you press <code>p<\/code> and enter the password before editing an entry) and encrypt the disks. On servers, protect the control panel account that gives console access with a strong password and two-factor authentication.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">GRUB&#8217;s recovery mode, command line and <code>grub rescue&gt;<\/code> shell let you repair a system that won&#8217;t boot, reset a forgotten password and fix boot problems without reinstalling. Before any repair, make sure you have an up-to-date backup of your important data.<\/p>\n\n\n\n<p class=\"snc-related wp-block-paragraph\" data-snc=\"rel20261105\"><strong>Related:<\/strong> <a href=\"https:\/\/sunucun.com.tr\/blog\/linux-boot-managers-and-multibooting\/\">Linux Boot Managers and Multibooting<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>GRUB (GRand Unified Bootloader) is the boot loader that loads the operating system on most Linux systems. When a system won&#8217;t boot, a password has been forgotten or an update has left the machine in a bad state, GRUB&#8217;s recovery options let you repair it without reinstalling. In this article we explain how to open&hellip;<\/p>\n","protected":false},"author":1,"featured_media":21571,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[1520],"tags":[],"class_list":["post-9700","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts\/9700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/comments?post=9700"}],"version-history":[{"count":2,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts\/9700\/revisions"}],"predecessor-version":[{"id":19730,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts\/9700\/revisions\/19730"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/media\/21571"}],"wp:attachment":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/media?parent=9700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/categories?post=9700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/tags?post=9700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}