Software

Changing Forgotten Password on Linux: It Only Takes 5 Minutes

Changing Forgotten Password on Linux: It Only Takes 5 Minutes

The physical availability of a computer by an attacker exposes the user’s data to the risk of theft. Unless the contents of the drives are protected through reliable cryptographic mechanisms. In this article we see how simple it is change the forgot password on Linux: a procedure that takes just 5 minutes.

The only important step to change the password of any account using Linux, consists of accessing GRUB, a well-known bootloader used to start operating systems. GRUB allows you to choose the platform to boot when the computer boots.

The steps shown below are for the Linux distribution Ubuntu but the same mechanisms are in fact applicable to any other penguin distro.

How to change a forgotten password on Linux

To force a password change when the PC starts, you must first access the GRUB boot menu. The GRUB main screen looks very similar to the one shown in the figure. If GRUB does not appear, you can press the button MAIUSC or several times ESCuntil the same menu appears.

GRUB Linux boot menu

At this point, using the arrow keys, you need to select the boot option Advanced options (it is highlighted in the figure above). On the following screen, you need to make sure you choose the item it says Recovery mode in brackets, then pressing the Enter key.

Recovery mode Linux

Acting on the next Recovery menuyou must select Root and press Enter to open a shell with the highest user privileges. At the bottom, the message appears Press Enter for maintenance: simply use the Enter key to continue, then type the following command:

mount -rw -o remount /

Change forgotten password on Linux

The command enables i write permissions on the root partition: by default, in fact, access is only possible for reading. The reference -rw (read/write) is unambiguous.

Typing ls /home, you get the list of user accounts present on the machine. This step is useful for verifying the exact name of the user whose password you want to change. In the example, we change the account password michele.

Passwd Linux command password change

The command passwdfollowed by the account name, allows you to change your password (it is not necessary to know the password already set). If the password indicated is not sufficiently secure, Linux displays a warning message.

Lastly, typing exit therefore choosing resumeyou can request the normal startup of the installed Linux distribution. By choosing the account for which you forgot the password and typing the one you just chose, you will be able to access the desktop.

Use GRUB editor to change forgotten password

A slightly different approach to changing a forgotten password for any Linux user account is to wait for the GRUB menu to appear when the machine boots and then press the E key to access the bootloader editor.

Corresponding to the line starting with linuxyou must locate the string ro (read only) and change it to rw (read/write). Furthermore, at the end of the same line, you must add init=/bin/bash.

This last intervention tells the Linux kernel to directly start a shell bash at boot, rather than going through the normal system initialization process. This means that once the system boots, GRUB presents the bash, without system services or other software components being started.

Linux boot GRUB editor

It should be borne in mind that the keyboard layout in this case it can create some problems. The equals symbol (=) is obtained by pressing the ^/ì key on the Europen keyboard; the backslash (/) is obtained by pressing the -/_ key.

Finally pressing the key combination CTRL+Xthe system reboots showing the bash shell.

Cambio password bash Linux

The command passwd, followed by the account name, allows you to define a new password. In this case, we suggest avoiding the use of special symbols within the password. The keyboard layout could in fact play tricks on you. We therefore suggest using only letters and numbers, finally restarting the Linux machine.

Opening image credit: iStock.com – gdainti

Leave a Reply

Your email address will not be published. Required fields are marked *