J'ai perdu mon mot de passe sous Linux ! Voici comment récupérer un accès à votre ordinateur.

2 min read 2 hours ago
Published on Jan 16, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial will guide you through the process of recovering access to your Linux computer when you have forgotten your password. The method described here is applicable to Ubuntu and other distributions using GRUB. Follow these steps to reset your password without needing to know your current one.

Step 1: Boot into Recovery Mode

  1. Restart Your Computer: Begin by rebooting your Linux machine.
  2. Access GRUB Menu: As your computer starts up, press and hold the Shift key (or Esc key) to access the GRUB menu.
  3. Select Recovery Mode:
    • Look for a line that includes “(recovery mode)” in the boot options.
    • Use the arrow keys to highlight it and press Enter.

Step 2: Access the Root Shell

  1. Choose Root Option: In the recovery menu, select the option that says "Drop to root shell prompt".
  2. Remount the Filesystem: By default, the filesystem is mounted as read-only. To change your password, you need to remount it with write permissions. Enter the following command:
    mount -o remount,rw /
    

Step 3: Change the Password

  1. Identify Your Username: If you don’t remember your username, type ls /home to see a list of user directories.
  2. Change the Password: Use the passwd command followed by your username:
    passwd your_username
    
    Replace your_username with your actual username. You will be prompted to enter a new password.

Step 4: Reboot the System

  1. Exit the Root Shell: Type exit to leave the root prompt.
  2. Select the Reboot Option: Choose the option to resume normal boot from the recovery menu, or reboot using:
    reboot
    

Conclusion

You have successfully reset your Linux password using recovery mode. After rebooting, you can log in with your new password. It’s a good practice to keep your passwords secure and consider using a password manager to prevent future lockouts. If you encounter any issues, consult the relevant documentation for your specific Linux distribution or seek help from community forums.