Change Linux Password
This guide explains how to change a user’s password on Linux, both in a normal environment and in recovery mode.
Changing Password in Normal Mode
Open Terminal:
- For desktop systems, open the terminal via the application menu.
- For servers, log in via SSH or the local console.
Set the Password: Enter the following command:
passwd
- You will be prompted to enter your current password.
- Then, you can set a new password.
Confirmation: If the change is successful, a confirmation message will appear.
Changing Password in Recovery Mode
If the normal password is forgotten, it can be changed through recovery mode:
Step 1: Access GRUB Boot Menu
- Restart the system.
- During the boot process, hold the Shift key (for BIOS systems) or Esc key (for UEFI systems) to open the GRUB menu.
Step 2: Edit Boot Line
- Select the entry for your operating system and press
e
to edit the boot options. - Locate the line starting with
linux
, for example:linux /boot/vmlinuz-... root=UUID=... ro quiet
- Replace
ro quiet
with:rw init=/bin/bash
Step 3: Boot into Root Shell
- Press Ctrl + X or F10 to boot with the modified settings.
- You will be taken directly to a root shell.
Step 4: Change the Password
- Set a new password for the
root
user:passwd root
- If another user account is affected, reset its password:
passwd <username>
Step 5: Save Changes and Restart
- Sync the filesystem changes:
sync
- Restart the system:
reboot -f
Tips and Notes
- Choose a strong password with a combination of uppercase and lowercase letters, numbers, and special characters.
- For server systems, consider using SSH keys as an alternative to passwords.
Note: This guide works for most Linux distributions (Debian, Ubuntu, CentOS, Fedora, etc.). Variations may occur depending on specific configurations.
+++