There is an SD card with Linux on which you need to reset the password and flash drive with Ubuntu 16.04LTS which I run without installation.

What am I doing wrong? As I understand it, you need to mount the SD card image to Ubuntu and then change the root password for Linux to the Flash card using the passwd command, but this command does not even want to work in the console, is it because Ubuntu is running in demo mode?

  • forgot chroot to flash drive - Naumov
  • Give your dialogue with the system, what commands you enter and what you get in return. - sercxjo

2 answers 2

If you have mounted the root partition of the system in which you need to change the password to a directory, for example /mnt , then you can change the root password on this system using the chroot program:

 $ sudo chroot /mnt passwd 

or to her, but implicitly, through the passwd option -R ( --root ):

 $ sudo passwd -R /mnt 
  • In this method there are two "pitfalls": 1) In order to "mount the root partition of the system," you must first unmount it .... And how are you going to unmount '/' while the system is running ?! 2) In this not very clear situation, you should already have root rights ... Where did they come from? - Sergey
  • @Sergey, 2. a live system is loaded, in which by default the user has the right to use sudo. 1. The root of another system, not the one that is loaded, is mounted. - aleksandr barakin

"Change" password is impossible in principle. It is stored in encrypted form and nobody knows it, except for the user.

What you call “change” is done in two steps: 1) CANCEL the root password 2) SET the root password

Step 2 is performed by regular means using the passwd command when the OS is operating normally.

But step 1 can be performed only if the OS is running in a SINGLE USER mode - this is an emergency recovery mode of the system.

How to boot the OS in this mode depends on the bootloader used to boot the OS. In most cases, you need to have time to get into the boot mode selection menu and select the "Single user mode" item there.

After that, go to the directory / etc and with any text editor, edit the passwd file, making the second field in the root line empty, like this 'root ::'. Then we reboot as usual.

However, most likely, all this will be useless, since modern versions of Linux do not allow you to log in to the system as root in principle! No Evidence of this is the symbol 'x' or '*' in the root password field in the "shadow" file. This suggests that you can start processes as root, but it is impossible to login as root.

  • 2
    You tell something strange. Unable to find out the old root password. Change to new - elementary. Only the rights of the root in the current system or disk access from any other system are needed. What the author of the question does is load into another system. - Shallow
  • @Sergey, the last paragraph of the answer (which starts with “however”) contains exactly incorrect information. - aleksandr barakin
  • The last paragraph of the answer (which starts with “however”) contains exactly incorrect information - try to login as root in Ubuntu :-) Write about the result! - Sergey
  • Unable to find out the old root password. Change to new - elementary. ** - very interesting reasoning! Those. we ** can elementary CHANGE what we don't know ?! I said quite definitely - you can RESET the root password, but it is impossible to CHANGE it. - Sergey
  • Only the rights of the root are needed in the current system - And how are you going to get the rights of the root without knowing its password? :-) I clearly said - you need to load the system in SINGLE USER mode! In this mode, the very concept of access rights loses its meaning. How to do this depends on the specific OS version and bootloader. In the extreme case, you can even unhook the HDD and attach it to another computer on which you have an account. - Sergey