Resetting the root password in linux

Reset lost root password

This guide will show you how to reset a forgotten root password. Several methods are listed to help you accomplish this.

Contents

Using sudo

If you have installed sudo and have configured permissions for either the wheel group or a user whose password you recall, you can change the root password by running sudo passwd root .

Using the debug shell

  1. Append systemd.debug_shell to the kernel parameters.
  2. This will do a normal boot but start debug-shell.service which runs a root shell ( /bin/sh ) on tty9 . Press Ctrl+Alt+F9 to access it.
  3. Use the passwd command to create a new password for the root user.
  4. When done, stop debug-shell.service .

Using bash as init

  1. Append the init=/bin/bash kernel parameter to your boot loader’s boot entry.
  2. Your root file system is mounted as read-only now, so remount it as read/write: mount -n -o remount,rw / .
  3. Use the passwd command to create a new password for the root user.
  4. Reboot by typing reboot -f and do not lose your password again!

Using a LiveCD

With a LiveCD a couple methods are available: change root and use the passwd command, or erase the password field entry directly editing the password file. Any Linux capable LiveCD can be used, albeit to change root it must match your installed architecture type. Here we only describe how to reset your password with chroot, since manual editing the password file is significantly more risky.

Источник

How to Reset the Root Password in Linux

In Linux, regular users and superusers are allowed to access services via password authentication. In the case a regular user can’t remember his/her password, a superuser can reset the password of a regular user right from the terminal. However, what if the superuser (or root user) loses his/her password? They will have to recover the lost password prior to booting into the login screen. This allows any malicious user with physical access to your Linux host to gain complete ownership. This article takes a look at how to recover a lost root password in Linux using two different methods.

Note: the method of resetting a root password is similar for most distros. Here we demonstrate the process using Ubuntu. We are also using “root password” throughout the tutorial for simplicity, but it can be interpreted interchangeably as the superuser password.

Also read: How to Easily Rename Files in Linux

1. 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.

Читайте также:  Windows 10 ноутбук regbnm

4. Press F10 . This will display a screen with a prompt.

5. Mount your root file system in read-write mode:

6. You can now reset your lost root password by using the following command:

Once you are done, type:

This will exit the prompt and reboot the computer.

Also read: How to Mount a Windows Share Folder on Linux

2. 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.

3. Open the terminal and type the following command to become root:

4. Find the location of the hard disk partition using the following command:

In most cases it will be “/dev/sda1,” although it can differ depending on how your hard disk is partitioned.

5. Mount the hard disk partition of the system to be recovered using the following command:

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.

7. Use the following command to reset your Linux root password:

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.

Changing the root password in Linux is easy once you get over the intimidation of the extra steps you have to take. Do note that anyone who has access to your computer can use this method to reset your superuser or root password. If you would like to be more cautious with who has access to these sorts of privileges, you should encrypt your hard disk so that it can’t be booted into or mounted easily.

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?

In most cases, the root user is the same as the superuser. Changing the root password should also change the superuser password. In Ubuntu, the superuser is the one with User ID 0. If you have configured another user with the UID 0, then in this case, the root and superuser passwords are not the same.

3. Can I create an expiration date for passwords?

Yes, you can! Using the -x flag, you can set the lifespan for the password of a particular user. For example, typing passwd -x 30 root will make the root password valid for only 30 days. Upon expiration, you must change the password.

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!

Читайте также:  Windows chromebook acer c720

Miguel has been a business growth and technology expert for more than a decade and has written software for even longer. From his little castle in Romania, he presents cold and analytical perspectives to things that affect the tech world.

Источник

Как сбросить пароль в Linux


Давайте рассмотрим несколько способов сбрасывания системного пароля в Linux. Вы наверное знаете, что у пользователя root есть права на изменение пароля любого пользователя в системе. А что если вы забыли пароль от рута? Вот об этом и пойдет речь в статье.

При восстановления пароля (рута или любого другого пользователя) встречаются две различные ситуации, требующие разного подхода.

Когда можно использовать GRUB

    После этого вы либо увидите приглашение для рута, либо восстанавливающее меню, где нужно выбрать строку с рутом. Используйте passwd для того чтобы изменить пароль у любого пользователя

  • Выполните команду reboot для перезагрузки системы и затем авторизуйтесь с новым паролем
  • Также следует заметить что некоторые дистрибутивы создают режим восстановления во время установки. Если в вашем меню GRUB есть такой пункт, вам не нужно производить все вышеперечисленные действия, просто выберите режим восстановления, а затем приглашение для рута, в последующем диалоговом окне.

    Когда нет возможности использовать GRUB

    Если вы не используете GRUB по каким-то причинам, вы можете восстановить пароль с помощью live CD (Я буду использовать Ubuntu live CD, вы можете взять любой другой). Просто следуйте дальнейшим инструкциям:

    • Загрузитесь с live CD
    • Выберите «Попробовать Ubuntu без изменений на вашем компьютере» (Try Ubuntu without any changes to your computer)

  • Когда система будет готова, запустите окно терминала и приготовьтесь к выполнению некоторых действий в командной строке
  • Напечатайте в окне терминала sudo fdisk -l. В результате мы узнаем, в какой раздел диска установлен линукс и непосредственно имя самого жесткого диска, в представленном примере нужный нам раздел называется /dev/sda1 . Если вы точно знаете нужный раздел, этот шаг можно пропустить.

    Далее нам нужно монтировать линукс-раздел. Для этого создайте папку, в качестве точки для монтирования, используя команду: sudo mkdir /media/linx_part

    Примонтируйте линукс-раздел командой sudo mount /dev/sda1 /media/linx_part

  • Измените рута в примонтированном разделе — sudo chroot /media/sda1
  • Используйте passwd для изменения текущего пароля на новый

    Источник

    How to Reset a Forgotten Root Password in Linux Mint

    It’s not unusual for users to forget their root passwords. It’s a common occurrence especially if you haven’t logged in as the root user for a long period of time. It can happen to the best of us. But don’t worry. In this guide, we will walk you through how you can reset a forgotten root password in Linux Mint.

    To get started, power on or reboot your Linux Mint system. After a few seconds, you should get a grub menu on the screen as shown below.

    Linux Mint Grub Menu

    On the first highlighted option, press ‘e’ on the keyboard to edit the grub parameters. You should get the screen shown below.

    Linux Mint Grub Parameters

    Next, scroll down using the arrow down cursor key until you get to the line beginning with ‘linux’ . Navigate until you get to the ro quiet splash section and add rw init=/bin/bash .

    Change Linux Mint Grub Parameter

    Then press ctrl + x or hit F10 to boot into a single-user mode as shown below.

    Linux Mint Single-User Mode

    To reset the forgotten root password in Linux Mint, simply run the passwd root command as shown.

    Specify the new root password and confirm it. If the password matches, you should get a ‘password updated successfully‘ notification.

    Reset Root Password in Linux Mint

    And finally, press Ctrl + Alt + Del to exit and reboot Linux Mint. You can now log in as the root user using the newly created password. And that’s how you can reset a forgotten root password om Linux Mint.

    If You Appreciate What We Do Here On TecMint, You Should Consider:

    TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

    If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

    We are thankful for your never ending support.

    29 thoughts on “How to Reset a Forgotten Root Password in Linux Mint”

    It’s not working in Linux Mint 19.2.

    Does not work in Linux Mint LMDE.

    Thank you very much I won’t have done it without you.

    Do not need to reboot just type:

    After sudo su type your user’s password to enter super user then try the procedure on it.

    Works on my Linux mint 19.3 cinnamon 🙂

    Way to go Quantro !

    sudo passwd root works in some cases in the single-line command given.

    If the system’s superuser and other system users are the same people, passwords for superuser and regular username with restricted permissions are different in both users.

    I was resetting the root password on my Linux Mint 20.1 Ulyssa 64-bit version earlier last month with a single-line comment

    I think it worked very well.

    Before I used Ubuntu variant Lubuntu 14 on my second Linux laptop brand new in the year 2005 and there was the solution by mounting your hard drive with reading and writing permissions before changing the password command in Recovery mode but like in this James Kiarie great blog post article, you have to reboot your system holding SHIFT-key.

    It’s not necessary anymore for Mint users’ to reboot the whole system I think nowadays.

    This option and possibility to reset admin’s and superusers passwords in Ubuntu and Mint make it there’s no way to use Mint or Ubuntu system in industrial use due to security issues what makes sense when Linux/Unix System Administration comes to industrial zone (For ie. Small company’s server for it needs excluding traffic outside of office’s IT Infra).

    Does not quite work in Linux Mint 20 in single-user mode,

    The solution, after doing: passwd root
    do passwd your username

    with your username (no caps) I suggest you set both the same password.

    I have an added problem it says I was successful at changing my password but it still doesn’t work to log in. Is there a way to eliminate the password? I have not been able to get into my computer for a while now.

    Running Linux Mint 20 updated on 1/1/2021 in single-user mode requiring entry of user password. Followed your instructions exactly and everything went as described. Entered and confirmed a new password and got “Password Successfully Changed”.

    Used F10 key to continued booting. Got Enter the Password login screen and entered the new password. It said “the wrong password” I tried the new password several times and still got “the wrong password” — So I entered the OLD password and log-in proceeded as normal. Did several reboots including one from the power-down state — no luck. The new password is not recognized by the OLD password is.

    So, as of January 1, 2021, the Grub modification of the root password does not seem to work. There is only one user on the system, so unless I don’t understand something the root password should be the Username password, right?

    I have tried everything possible to change the login password on my laptop, with no results. I’m using Linux mint 19.3 cinnamon. Any suggestions out there!!

    Thank you so much. Problem solved, thanks to your article.

    You are very much welcome,

    Got something to say? Join the discussion. Cancel reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Источник

    Читайте также:  Как создать свой репозиторий для linux
  • Оцените статью