Your password should be 8 characters or more and contain a mix of letters (upper and lowercase), numbers and symbols.
Thanks for submitting a tip for review!
- Пароль должен включать не менее 8 символов и содержать сочетание букв (прописных и строчных), цифр и символов.
- Чтобы изменить пароль для другого пользователя, введите su, чтобы получить права суперпользователя, а затем введите passwd <имя пользователя>.
It’s a good idea to change your passwords regularly and consider using enterprise password management software.
This guide will help you change your Linux root password in Ubuntu or CentOS, or reset the password.
- A computer running Linux
- Command-line interface (terminal)
This article intends to provide a solution to reset the root password on Ubuntu 22.04. What if the password is forgotten?
The GRUB boot loader acts as an escape plan to switch to a new root password. GRUB (GRand Unified Boot Loader) boot loader starts up from the BIOS and leads up to load the installed operating system. The GRUB boot loader will be used to reset the root password.
Choose the first option “Ubuntu” and enter inside it using the “e” key to edit a few settings.
Replace the line “quiet splash $vt_handoff” to “init=/bin/bash“. Moreover, change the permission from “ro” to “rw” as well.
After that, press CTRL+X or F10 to boot with the above written settings.
Upon successful execution of the command, you need to enter a new password. For confirmation, it will ask to enter the password again. After doing so, the password will be updated.
- Conclusion
- How to Reset the Root Password on Debian 9 Stretch
- Installing and Configuring sudo
- Setting Root Password
- Changing Root Password
- Disabling Root Login
- Recovering Lost Root Password
- About the author
- Option 1: Changing Ubuntu Password in the Command Line
- Option 2: Change sudo Password with the passwd Command
- Option 3: Changing Ubuntu Password Using GUI
- Step 1: Reboot your Ubuntu 20.04 LTS Operating System and load the GRUB menu by holding the Shift Key on Keyboard
- Step 2: Press ‘e’ to edit the commands
- Step 3: Edit the clause of the second last line from ‘ro quiet splash $vt_handoff’ to ‘rw init=/bin/bash’
- Step 4: Press F10 or Ctrl-x to save the edits and boot
- Step 5: Type the command ‘mount | grep -w /’ to confirm the read and write access rights
- Step 6: Type the ‘passwd’ command and provide the new password for the root
- Step 7: Type the command ‘exec /sbin/init’ to reboot your Ubuntu 20.04 LTS Operating System
- Conclusion
- About the author
- Resetting a Root Password in Ubuntu
- Step 1: Boot to Recovery Mode
- Step 2: Drop Out to Root Shell
- Step 3: Remount the File System with Write-Permissions
- Step 4: Change the Password
- Changing the Root Password in CentOS
- Step 1: Access the Command Line (Terminal)
- Step 2: Change the Password
- Step 1: Access Boot Menu
- Step 2: Edit Boot Options
- Step 3: Remount the Drive
- Step 4: Changing the Password
- Step 5: Restart
- Об этой статье
- Reset Lost Linux Root Password from the Grub Menu
- Changing Your Root Password in Ubuntu
- Step 1: Open a Terminal Window
- Step 2: Change Your Root Password
- Сбрасываем пароль от root через GRUB
- Frequently Asked Questions
- 1. How does full disk encryption affect my ability to change my root password?
- 2. What is the difference between root and superuser password?
- 3. Can I create an expiration date for passwords?
- Reset Lost Root Password Using Live CD
- About This Article
Conclusion
ROOT-пользователь — это пользователь с правами администратора, созданный по умолчанию в Linux-системе (Ubuntu). Root аналог администратору в ОС Windows, который имеет доступ ко всему в системе.
Этот способ предполагает вход в систему Ubuntu под пользователем с sudo правами, а команда «su» разрешена как часть «sudo» привилегий.
sudo su
Глядя на скриншот выше, можно заметить смену пользователя на «root», таким образом, мы вошли в Ubuntu под root, используя свой пароль.
Теперь мы можем сменить пароль root-пользователя, для этого необходимо использовать следующую команду:
passwd
После ввода команды указываем новый пароль в запросе «New password» и повторяем новый пароль после запроса «Retype new password».
Пароль для root будет установлен при первом использовании команды или изменит его на новый пароль при дальнейших использованиях команды «passwd».
А работает ли новый пароль? Давайте это выясним, нажимаем сочетание клавиш «Ctrl+D», чтобы окончить текущий ввод данных в терминале, либо запускаем новый терминал и вводим новую команду:
su
Данной командой мы войдем в систему как root, после чего вводим новый пароль, который мы только что установили для root.
Таким образом мы успешно изменили пароль от root.
How to Reset the Root Password on Debian 9 Stretch
In this article, I will show you how to configure sudo, set root password, disable root login and reset root password. This can be done even if you don’t have sudo enabled and you don’t remember the password. Let’s get started.
Installing and Configuring sudo
Now type in your root password and press <Enter>.
The apt package repository cache should be updated.
It should be installed. In my case it is already installed.
The command should run as root as you can see from the screenshot below.
Setting Root Password
Now type in your desired root password and press <Enter>.
Now retype the root password and press <Enter>.
The root password should be set. Now you can login as root using your root password.
Changing Root Password
Now do the same things as you did on the Setting Root Password section of this article.
Disabling Root Login
Recovering Lost Root Password
If you happen to forget the root password and you don’t have sudo configured, then don’t give up just yet and think about reinstalling the operating system again. There is a way to reset the root password.
First reboot your computer. You should see the GRUB menu when your computer boots as shown in the screenshot below. Select Debian GNU/Linux and press e.
Now remove ‘ro quiet’ part from the end of the line and append ‘init=/bin/bash’ to the end of the line as marked in the screenshot below. Once you’re done, press F10.
remount,rw proc
Now type in your new root password and press <Enter> to continue.
Now re-type your new root password and press <Enter> to continue.
You root password should be changed.
Now press <Ctrl> + <Alt> + <Delete> and your Debian 9 Stretch machine should reboot.
Now you can login as root with your new root password as you can see in the screenshot below.
This is how you reset your root password on Debian 9 Stretch. Thanks for reading this article.
About the author
Are you looking to change the root password in Ubuntu?
Changing passwords is a good practice and should be done periodically.
There are three (3) ways to change passwords in Ubuntu.
The first two (2) options use the command line, and the other uses Linux’s graphical interface (GUI).
- Ubuntu installed and running
- A user with sudo privileges
- Access to a terminal/command line
- The apt-get tool, pre-loaded in Ubuntu and other Debian-based distros
Option 1: Changing Ubuntu Password in the Command Line
To change the sudo password using the sudo
command:
1. First, open the terminal using the keyboard shortcut CTRL+ALT+T.
2. Query for a password change by running the command:
sudo passwd root
You will be prompted to enter and verify a new password. The output will inform you the password was updated successfully.
Option 2: Change sudo Password with the passwd Command
1. First, open the terminal (CTRL+ALT+T).
sudo –i
Type in your current password and hit Enter. The output you receive should show that you can now run commands as root.
3. Next, change the password by running the command:
passwd
Type and retype a new password to verify the change.
exit
5. Exit out of the terminal with the same command:
exit
Option 3: Changing Ubuntu Password Using GUI
To change the default root password in Ubuntu without using the terminal or any commands, use the graphical interface.
1. Open the Activities overview by pressing the Windows or Super key.
2. Type settings in the search bar and click on the Settings icon.
3. In Settings, click on the Details card (which is most likely the last one).
5. This will open a new Change Password pop-up. Type in your current root password, your new root password and verify the new password by retyping it.
6. Once you have filled in all the fields, click Change to confirm the changes.
Finally, make sure that your password includes both lower and upper case letters, numbers and special characters. It is essential to have a strong password to prevent brute force attacks.
This wikiHow teaches you how to change the Linux root password if you have the current password or if you don’t have access to the current root password.
-
- If you’re not using a desktop environment, you’re already at a command prompt, so proceed to the next step.
-
-
- If you type the password incorrectly, run su and try again.
- Passwords are case-sensitive.
-
Type passwd and press . An Enter new UNIX password: line will appear below the prompt.
-
Type a new password and press . The password you type will not appear on the screen.
-
Retype the new password and press . You will see a message that reads “password updated successfully.”
-
Type exit and press . This will log you out of the root account.
-
Restart your computer.
-
- If you don’t press before the Grub menu disappears, reboot and try again.
- This method works for most popular Linux distributions (Ubuntu, CentOS 7, Debian). There are many distributions of Linux, some more obscure than others. If you’re not able to get to single-user mode with this method, check your distribution’s website for instructions specific to your system.
-
- In CentOS and some other distributions, the line may begin with linux16 rather than linux.
-
-
Type init=/bin/bash after ro. The end of the line should now look like this:
ro init=/bin/bash
.- Note the space between
ro
andinit=/bin/bash
.
- Note the space between
-
-
Type mount –o remount,rw / at the prompt and press . This mounts the file system in read-write mode.
-
-
Type a new root password and press . The characters you type won’t be displayed on the screen. This is normal.
-
Retype the new password and press . When the system confirms you’ve re-entered the same password, you’ll see a message that reads “password updated successfully.”
-
Type reboot –f and press . This command reboots the system normally.
Add New Question
How do I find the current password?
If you have lost your current root password, you may need to use a password cracking tool to get it back. Depending on the strength of the password you set, this could be either very easy or very difficult. John the Ripper is a popular password cracking tool that might work for you.
I am facing an authentication failure problem even after using a valid password. What can be the reason?
I have tried this. The first time it works well, but not the second. I notice my linux line does not have the /boot/, can it still work?
If your linux line does not have /boot/ and it does not boot up then you have broken your GRUB. You will need to re-add this line to boot your computer. If there is another path then just add the required things after «ro» on the linux line.
See more answers
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Из этой статьи вы узнаете, как в Linux изменить пароль суперпользователя, если вы знаете текущий пароль, и если вы его не знаете .
-
- Если вы не пользуетесь средой рабочего стола, вы уже находитесь в терминале, поэтому перейдите к следующему шагу.
-
-
Введите текущий пароль суперпользователя, а затем нажмите . Если введен верный пароль, вы получите права суперпользователя.
- Если вы ввели неверный пароль, введите su и повторите попытку.
- Пароли чувствительны к регистру.
-
Введите passwd и нажмите . На новой строке появится Enter new UNIX password: (Введите новый пароль).
-
Введите новый пароль и нажмите . Вводимый пароль не будет отображаться на экране.
-
Введите новый пароль еще раз и нажмите . Вы увидите сообщение «Password updated successfully» (Пароль успешно обновлен).
-
Введите exit и нажмите . Вы выйдете из аккаунта суперпользователя.
-
-
- Если вы не успели нажать , и меню Grub исчезло с экрана, перезагрузите компьютер и попробуйте снова.
- Этот метод работает в большинстве популярных дистрибутивов Linux (Ubuntu, CentOS 7, Debian). Существует много дистрибутивов Linux, и если у вас не получается перейти в однопользовательский режим с помощью этого метода, почитайте инструкции к своему дистрибутиву (на сайте его разработчиков).
-
Перейдите к строке, которая начинается с linux/boot. Для этого используйте клавиши и . Эту строку нужно изменить, чтобы загрузиться в однопользовательском режиме.
- В CentOS и некоторых других дистрибутивах нужная строка начинается с linux16, а не linux.
-
-
Введите init=/bin/bash после ro. Конец строки должен выглядеть следующим образом:
ro init=/bin/bash
.- Обратите внимание на пробел между
ro
иinit=/bin/bash
.
- Обратите внимание на пробел между
-
Нажмите . Это сообщит системе о том, что в однопользовательском режиме нужно сразу открыть терминал с правами суперпользователя.
-
Введите mount –o remount,rw / в терминале и нажмите . Это приведет к монтированию файловой системы в режиме чтение/запись.
-
Введите passwd в терминале и нажмите . Так как в однопользовательском режиме вы автоматически получаете права суперпользователя, нет необходимости добавлять в эту команду дополнительные параметры.
-
Введите новый пароль суперпользователя и нажмите . Вводимый пароль не будет отображаться на экране.
-
Введите новый пароль еще раз и нажмите . Когда система подтвердит, что оба пароля совпадают, вы увидите сообщение «Password updated successfully» (Пароль успешно обновлен).
-
Введите reboot –f и нажмите . Эта команда перезагрузит систему в обычном режиме.
You have forgotten your root password, and now you have no idea how to retrieve your Ubuntu 20.04 LTS Operating System? In this post, we will guide you on how to reset your root password on Ubuntu 20.04 LTS System from the GRUB menu. The Grand Unified Bootloader or GNU GRUB menu is a boot loader and software or program that loads and transfers control to the Operating System like Linux- it runs when a computer starts. So, let’s begin with the step-by-step guide of resetting the password of the root.
Step 1: Reboot your Ubuntu 20.04 LTS Operating System and load the GRUB menu by holding the Shift Key on Keyboard
The first step is to start your computer machine and keep pressing the shift button on your keyboard until the GRUB menu appears, as shown in the picture below:
Step 2: Press ‘e’ to edit the commands
Now, select the boot Operating system, which is Ubuntu in our case, and press the ‘e’ key on your keyboard to edit some commands. By doing so, we can load the root shell Command prompt. Pressing the ‘e’ key on your keyboard allows you to have an edit screen, as shown in the picture below:
Step 3: Edit the clause of the second last line from ‘ro quiet splash $vt_handoff’ to ‘rw init=/bin/bash’
After entering into the editing mode of commands, scroll down until the last, find a line that starts with the word ‘linux’ and change the last clause of this line that reads ‘ro quiet splash $vt_handoff’ to this clause, ‘rw init=/bin/bash’, as shown in the pictures below:
ro quiet splash $vt_handoff
Step 4: Press F10 or Ctrl-x to save the edits and boot
Once you have edited the line for loading the root shell command prompt, Press F10 or CTRL+X to save and boot the system. After the reboot, a shell command prompt screen of the root will appear, as shown in the picture below:
Step 5: Type the command ‘mount | grep -w /’ to confirm the read and write access rights
In the root shell command prompt screen, type the command given below for confirmation of the read and write privileges.
Step 6: Type the ‘passwd’ command and provide the new password for the root
Once read and write access rights are confirmed, type the ‘passwd’ command and enter or set the new password for the root.
You can see that the password is updated successfully.
Step 7: Type the command ‘exec /sbin/init’ to reboot your Ubuntu 20.04 LTS Operating System
After successfully updating the password of the root, the last step is to just reboot your system by typing the command given below:
After running the above command, your computer will reboot and load the welcome screen of the Ubuntu 20.04 LTS system.
Conclusion
The article contains a step-by-step and easy-to-understand guide on how to reset your forgotten root password on the Ubuntu 20.04 LTS system.
About the author
A Javascript Developer & Linux enthusiast with 4 years of industrial experience and proven know-how to combine creative and usability viewpoints resulting in world-class web applications. I have experience working with Vue, React & Node.js & currently working on article writing and video creation.
Resetting a Root Password in Ubuntu
In some situations, you may need to access an account for which you’ve lost or forgotten a password.
Step 1: Boot to Recovery Mode
Restart your system. Once you see the splash screen for the computer manufacturer, hold down the shift key. The system should come up with a black and white GRUB, or boot menu, with different Linux kernel versions displayed.
Step 2: Drop Out to Root Shell
The system should display a menu with different boot options. Use the arrow keys to navigate to the option labeled root and press Enter.
The system should respond by giving you a command-line interface with a prompt.
Step 3: Remount the File System with Write-Permissions
Right now, your system only has read-only access to your system. That means it can look at the data, but cannot make any changes. But we need write-access to change the password, so we’ll need to remount the drive with the appropriate permissions.
At the prompt, type:
mount –o rw,remount /
Press Enter. This should allow you to make changes to the data on the hard drive.
Step 4: Change the Password
At the prompt, type:
passwd username
shutdown –r
Hit Enter, and your system should restart. Don’t press any keys, let the system come up to the login screen, and test to make sure the new password works.
Note: Learn how to use the chpasswd command. Chpasswd is helpful for managing multiple passwords and making multiple changes.
Changing the Root Password in CentOS
Changing a password in CentOS is almost identical to changing it in Ubuntu.
Step 1: Access the Command Line (Terminal)
Right-click the desktop, then left-click Open in Terminal. Or, click Menu > Applications > Utilities > Terminal.
Step 2: Change the Password
sudo passwd root
This is a similar process as in Ubuntu, with a couple of variations.
Step 1: Access Boot Menu
Restart the system, then tap the Esc key about once per second to launch the GRUB menu.
Step 2: Edit Boot Options
Use the arrows to highlight the version of Linux you boot into, then press e.
Use the arrows to highlight the line that starts with kernel or Linux.
Step 3: Remount the Drive
mount / -o remount,rw
Step 4: Changing the Password
passwd
Press Enter, and the system should prompt you to enter and confirm a new password.
Step 5: Restart
mount / -o remount,ro
sync
reboot
Your system should restart. Confirm that your new password works by logging in.
Note: If you ever come across a Linux boot failure, be sure to save our guide on using GRUB rescue to troubleshoot it.
It can be more challenging if you’ve lost or forgotten a password, but with a little creative restarting and editing, you shouldn’t find it too hard.
Об этой статье
Reset Lost Linux Root Password from the Grub Menu
1. First and foremost, to recover a lost root password, we need to restart the Linux host, assuming you forgot the password for root.
2. Once the GRUB page appears, quickly select the “*Advanced options for GNU/Linux” option by pressing the down arrow key and Enter button.
3. Now press e to edit the commands.
You need to modify it or change it from “read-only” mode to “read-write” mode. Find the line beginning with “Linux.” Look for ro
and change it to rw
. Add init=/bin/bash
at the end of the line.
4. Press F10. This will display a screen with a prompt.
5. Mount your root file system in read-write mode:
Once you are done, type:
This will exit the prompt and reboot the computer.
Changing Your Root Password in Ubuntu
Step 1: Open a Terminal Window
Right-click the desktop, then left-click Open in terminal.
Alternately, you can click Menu > Applications > Accessories > Terminal.
Step 2: Change Your Root Password
sudo passwd root
The system will prompt you to enter your password – this is the same password you use to log in to the system.
Next, the system will prompt you to enter a new password. Do so, and then re-enter it exactly the same when the system prompts you to retype the password. This double-entry confirms that you have typed the password correctly.
Сбрасываем пароль от root через GRUB
Существует еще один способ для изменения пароля от root или любого другого пользователя при загрузке Ubuntu.
Сначала перезагружаем наш ПК. Если меню GRUB не появляется автоматически, то удерживаем клавишу «Shift» во время загрузки. Это принудительно откроет меню GRUB.
Затем выбираем пункт «Ubuntu» в меню и нажмите клавишу «E», чтобы начать редактирование конфигурации загрузки.
Далее необходимо внести изменения в строку, заменяем значение:
quiet splash $vt_handoff
rw init=/bin/bash
Результат отображен на скриншоте ниже:
Изменения заключаются в том, чтобы из GUI перейти в оболочку Bash для внесения изменений — смена пароля. Нажимаем клавишу «F10», чтобы загрузиться с новой конфигурацией.
Загрузка с измененной конфигурацией сработает только один раз и сброситься при повторной загрузке.
Мы вошли в систему как root-пользователь в командной строке. Теперь используем команду для сброса пароля:
passwd
Указываем и повторяем новый пароль.
Затем перезагружаем систему в обычном режиме (без GRUB) и входим как root уже с новым паролем.
Frequently Asked Questions
1. How does full disk encryption affect my ability to change my root password?
Although encryption can complicate things when you’re trying to repair a problem on Linux, this is not the case when you’re trying to change the root password. You can still do it easily from grub as described above as long as you are able to gain access to the disk.
The only difference now is that outsiders won’t be able to just slide in and do the same themselves.
2. What is the difference between root and superuser password?
3. Can I create an expiration date for passwords?
Additionally, you could use the -w
flag to set the number of days required for an advanced warning about the need to change the password . Typing passwd -w 7 root
will send you warnings about changing the root password a week prior to the deadline you previously set with the -x
flag.
Want to keep digging into Linux? We have a guide for setting up Bluetooth on Linux. You can also check out our list of tools to create your very own Linux distro!
Subscribe to our newsletter!
Our latest tutorials delivered straight to your inbox
Reset Lost Root Password Using Live CD
If you have a Linux Live CD/USB, then you can boot into it and use it to reset the root password.
1. Download the latest version of Ubuntu, and create a bootable Live CD/USB from it. Boot your system from the removable drive as opposed to your hard drive.
2. On the display screen select “Try Ubuntu.” This will bring you to the Live CD desktop.
In most cases it will be “/dev/sda1,” although it can differ depending on how your hard disk is partitioned.
mntrecover devsda1 mntrecover
6. At this point we need to jail ourselves in the “mnt/recovery” directory. This means that we are pretending to be on the regular Linux filesystem. This is simply known as chrooting.
8. Once completed, exit from the chroot shell:
9. Unmount the root partition:
and exit your root:
10. Lastly, remove the Live CD and reboot into your Linux system.
About This Article
1. Type «su» and press Enter.
2. Enter the current password and press Enter.
3. Type «passwd ‘» and press Enter.
4. Confirm the new password and press Enter.
5. Type «exit» and press Enter.
Did this summary help you?
Thanks to all authors for creating a page that has been read 5,267,653 times.