How to change the root password in Linux

Table of contents:

How to change the root password in Linux
How to change the root password in Linux
Anonim

It is possible on Linux to change the administrator password whether or not you have the current one. It's very easy with the Command Prompt.

Steps

Method 1 of 2: With the administrator password

Change the Root Password in Linux Step 1

Step 1. Run a command prompt window (Terminal)

Use the keyboard combination Control + Alt + T. This combination allows most Linux distributions to open the command prompt.

If your Linux computer doesn’t run with a Desktop, you don’t need to do anything, you’re already at the command prompt

Change the Root Password in Linux Step 2

Step 2. Type su in the command prompt

Confirm with the Enter key. The line UNIX password (current): then appears in the command prompt.

Change the Root Password in Linux Step 3

Step 3. Type the current administrator password

Confirm with the Enter key. If the password is correct, you will remain on the command prompt with administrator status.

  • If you made a mistake while typing, retype su, then start over.
  • A password is always case sensitive.
Change the Root Password in Linux Step 4

Step 4. Type passwd, then validate with the Enter key

A line

Enter the new UNIX password: appears under the previous one.

Change the Root Password in Linux Step 5

Step 5. Type a new password

Then validate with the Enter key. The password for security reasons does not appear on the screen.

Change the Root Password in Linux Step 6

Step 6. Retype the password, then validate with Enter

If all went well, will be displayed the password has been updated successfully.

Change the Root Password in Linux Step 7

Step 7. Type exit, then validate with the Enter key

You are now logged out of your administrator account.

Method 2 of 2: Without the administrator password

Change the Root Password in Linux Step 8

Step 1. Restart your computer

Change the Root Password in Linux Step 9

Step 2. From the Grub menu, press E

Grub runs when your computer starts up and it only stays on the screen for a few seconds.

  • If you don't press the E key before the Grub menu disappears, restart … and be faster.
  • This method works on most major Linux distributions (Ubuntu, CentOS 7, Debian). Now if you have an exotic linux distro understand rare you might not be able to switch to single user mode. If so, go to the designer's site to learn more.
Change the Root Password in Linux Step 10

Step 3. Move the cursor down to the linux / boot line

To do this, use the arrows ↑ and ↓ on your keyboard. It is on this line that the change will be made which allows you to restart in single user mode.

  • With CentOS and a few other distributions, the line will start with

    linux16, while for other distributions it will be through linux.

Change the Root Password in Linux Step 11

Step 4. Move the cursor to the end of the line

To do this, use the navigation arrows on your keyboard: →, ←, ↑ and ↓. The cursor must be after

ro.

Change the Root Password in Linux Step 12

Step 5. After ro, type init = / bin / bash

The line that ended in

ro

now ends with:

ro init = / bin / bash

.

  • Be careful to leave a space between

    ro

    and

    init = / bin / bash

    .
Change the Root Password in Linux Step 13

Step 6. Press Control + X

This combination allows you to reboot directly in single user mode with administrator account privileges.

Change the Root Password in Linux Step 14

Step 7. Type mount –o remount, rw / in the prompt

Then validate with the Enter key. This command mounts the system file in read and write mode.

Change the Root Password in Linux Step 15

Step 8. Type passwd, then validate with the Enter key

Single-user startup automatically gives you full administrator privileges, so you don't have to do any other settings.

Change the Root Password in Linux Step 16

Step 9. Type a new administrator password

Then validate with the Enter key. The password for security reasons does not appear on the screen.

Change the Root Password in Linux Step 17

Step 10. Retype the new password

Then validate with the Enter key. If the two password entries are the same, you will see the password has been updated successfully.

Change the Root Password in Linux Step 18

Step 11. Type reboot –f, then validate with the Enter key

This command allows a classic restart of your computer.

Advice

  • A good password should be at least 8 characters long, a subtle mix of letters (upper and lower case), numbers and special characters like @, # or &, etc.
  • To change the password for a single user, type su, then

    passwd.

Popular by topic