How to change root password in Linux

Author: John Stephens
Date Of Creation: 25 January 2021
Update Date: 16 May 2024
Anonim
How To Reset Linux Root Password
Video: How To Reset Linux Root Password

Content

This wikiHow article explains how to change root password in Linux operating system, applicable to the case you remember your current password or can't remember your root password.

Steps

Method 1 of 2: Where to remember the current root password

  1. Open a terminal window. To open this window, press Ctrl+Alt+T, to open up a new terminal window that has a Command Prompt (command line interpreter) in most Linux desktop environments.
    • If you're not using the desktop environment, you're already using the Command Prompt, so proceed to the next step.

  2. Type su in Command Prompt, then press ↵ Enter. Current Password: will open under the Command Prompt.

  3. Type your current root password, then tap ↵ Enter. Once the password is approved, you will return to the Command Prompt as the root user.
    • If you enter the wrong password, run su and try again.
    • Passwords are case sensitive.

  4. Type passwd and press ↵ Enter. Current Enter new UNIX password: will appear at the bottom of Prompt.
  5. Type in the new password and tap ↵ Enter. The password you type will not appear on the screen.
  6. Retype the new password and click ↵ Enter. You will see a message saying "password updated successfully" (password updated successfully).
  7. Type exit and press ↵ Enter. This step helps you log out of the root account. advertisement

Method 2 of 2: Where does not remember the current root password

  1. Restart the computer.
  2. Press E in the Grub menu. The Grub menu appears as soon as you turn on your computer. Usually, this menu only appears on the screen at a time.
    • If not, hit E before the Grub menu disappears, you need to restart your computer and try again.
    • This can be done with most popular Linux distributions (eg Ubuntu, CentOS 7, Debian). There are many Linux distributions out there, some of which are not well known. If you cannot switch to single-user mode in this way, you need to visit your distribution's website to see instructions specific to your system.
  3. Scroll down to the line that begins with linux / boot. Press the keys and to do this. You need to edit this line to start in single user mode.
    • In CentOS and a few other distributions the command line may start with linux16 instead linux.
  4. Move the cursor to the end of the line. Press the keys , , , and to immediately follow ro.
  5. Type init = / bin / bash after ro. Now the end of the line looks like this:
    ro init = / bin / bash.
    • Notice the space between ro and init = / bin / bash.
  6. Press Ctrl+X. This step causes the system to boot directly as a root-level decentralized Command Prompt in single user mode.
  7. Type mount -o remount, rw / Go to Prompt and press ↵ Enter. This step mounts the file system in read-write mode.
  8. Type passwd in Prompt and press ↵ Enter. When booting in single user mode, you get root access, so there's no need to write anything to the command. passwd.
  9. Type in the new root password and press ↵ Enter. The characters you type will not be displayed on the screen. This is normal.
  10. Retype the new password and click ↵ Enter. When the system confirms that you have re-entered the correct password, you will see “password updated successfully” (password is updated successfully).
  11. Type reboot –f and press ↵ Enter. This command helps in a normal system reboot. advertisement

Advice

  • Your password should contain 8 characters or more, a combination of many letters (upper and lower case), numbers and special characters.
  • To change the password for another user, use su to root and type passwd .