How to change the root password linux

How to change root password on Debian Linux

How to change root password on Debian Linux

The procedure for changing the password of root is as follows:

  1. First, log in to the Debian Linux server using ssh or console
  2. Open a shell prompt and type the passwd command to change root password in Debian Linux
  3. The actual command to change the password for root on Debian Linux is sudo passwd root

NOTE: Please note that [vivek@debian-linux9:

]$ is my shell prompt. You need to type commands after the $ prompt.

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

Debian Linux change root password command

I am going to log in to my Debian Linux 7.x/8.x/9.x server using the ssh command:
ssh vivek@debian-linux9
Once logged in enter the command passwd as follows:
[vivek@debian-linux9:

]$ sudo passwd root
First you need to type the password for vivek user. After that the passwd command asks for the new password, which you will have to enter two times:

Changing root account passwords on a Debian Linux based system

Slightly different procedure for changing passwords in Debian Linux

One can use the following procedure too:
[vivek@debian-linux9:

]$ ssh user@your-centos-server-name-ip
Become a root user via the su command or sudo command:
[vivek@debian-linux9:

]$ sudo -i
OR
[vivek@debian-linux9:

]$ su —
Finally change your root user password:
passwd

Conclusion

This page explained the process for changing the password of root user using the passwd command on a Debian Linux server 9.x. For more info see man page of the passwd command by typing the following man command:
man 5 passwd
man passwd
man 5 shadow

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

How to Change root Password on Linux

The root account has the ability to control anything on a Unix system, and Linux is no different. One has to use the passwd command to change Linux password data, and the same goes for root. Due to the special nature of this command, some precautions do apply. Notably, it’s not possible to change Linux password data for the root user readily on an Ubuntu or Ubuntu spin system without first making some changes.

A majority of users who want to change Linux password data will need to open a graphical terminal. You can hold down Ctrl, Alt and T to do so or perhaps click on the Applications menu, head to system tools and select terminal. CentOS users who don’t have a graphical interface installed will want to log into their virtual terminal with a user account, assuming they have the sudo packages updated.

Method 1: Change root Password on Most Linux Distributions

Assuming your distribution has the sudo package installed, you can change the root passwd with the sudo passwd root command. You’ll be asked for your sudo password first, and then you’ll have to enter a new UNIX password twice. Your password will be tested for complexity, so you’ll want to make sure that it’s good. Once you’ve entered the password in twice, your root account should be changed. Hold down Ctrl and Alt then push F1-F6 to get to an empty virtual terminal. Type root and then the new password to make sure it works. Considering the hazards related to working as root, make sure to type exit to get out of this console. Hold down Ctrl, Alt and F7 to get back to your graphical environment if you’re not working from a server. This method should work on Debian and many other distributions. It should also work with Arch if you have the all the prerequisite packages installed.

Читайте также:  Что будет если установить windows сразу

Method 2: Change root Password on Ubuntu Linux

Ubuntu and its various derivatives hash out the root account, which functionally disables it. You won’t be able to readily change out the password of the root user because it doesn’t really exist. This is true for Xubuntu, Kubuntu, Lubuntu and potentially most installations of Linux Mint and Trisquel. While it’s possible to activate the account, it’s not at all recommended. Keep in mind that your first user on these systems is an administrator and can access a root account by typing sudo -i at the prompt and entering your password. This works the same as any other root login, and it’s a good bit safer. If you’re absolutely certain that you want to activate the root account and understand the risks involved, then type sudo passwd root and push enter. Enter a new UNIX password and make sure you don’t forget it. You’ll then need to run sudo passwd -u root to unlock your account. You’ll get a message that reads something like “password expiry information changed,” which means you’ve opened the account. The root user will work like normal, but please keep in mind just how dangerous this actually is. When you want to disable the root account, you can type sudo passwd -dl root to lock it up again.

Method 3: Change Linux Password Data as root

If you’re logged in as root say on a CentOS, Fedora or Red Hat Enterprise Linux server’s virtual terminal, then you can change the password simply by typing passwd and then pushing enter. You’ll receive a prompt that reads “Enter new UNIX password:” and then you’ll be asked to type it a second time. Keep in mind that you should have actually logged into root in order to do this, or perhaps used sudo su to access a root prompt. This won’t work on an unaltered Ubuntu or Linux Mint system, but it’s good for those running server systems or using ssh to log into ones remotely. Make sure before you try this that you have # as the symbol in your prompt. Depending on the default login shell set for root, the prompt may have other bits of information in it.

Remember that regardless of what method or which distribution you’re working on, you can also type whoami and push enter to find out who you’re logged in as.

Источник

How to Reset or Change the Root Password in Linux

Home » SysAdmin » How to Reset or Change the Root Password in Linux

In Linux, root privileges (or root access) refers to a user account that has full access to all files, applications, and system functions.

Most basic Linux user accounts run with limited privileges. This keeps users from making mistakes or accidentally exposing the system to vulnerabilities.

To use protected operating system features, a Linux user has to temporarily elevate their privileges using a command like sudo . The sudo command tells the system to run a command as a superuser, or root user. When you run a function using sudo , you’ll usually have to enter your password.

Some versions of Linux will elevate your user privileges for a set amount of time around (15 minutes) before reverting. Other versions only perform a single task with elevated privileges.

It’s a good idea to change your passwords regularly and consider using enterprise password management software.

This guide will help you change your Linux root password in Ubuntu or CentOS, or reset the password.

Читайте также:  Как установить loic kali linux

  • A computer running Linux
  • Command-line interface (terminal)

Changing Your Root Password in Ubuntu

Step 1: Open a Terminal Window

Right-click the desktop, then left-click Open in terminal.

Alternately, you can click Menu > Applications > Accessories > Terminal.

Step 2: Change Your Root Password

In the terminal window, type the following:

The system will prompt you to enter your password – this is the same password you use to log in to the system.

Next, the system will prompt you to enter a new password. Do so, and then re-enter it exactly the same when the system prompts you to retype the password. This double-entry confirms that you have typed the password correctly.

Resetting a Root Password in Ubuntu

In some situations, you may need to access an account for which you’ve lost or forgotten a password.

Step 1: Boot to Recovery Mode

Restart your system. Once you see the splash screen for the computer manufacturer, hold down the shift key. The system should come up with a black and white GRUB, or boot menu, with different Linux kernel versions displayed.

Select the second one from the top – the highest revision, followed by (recovery mode). Press Enter.

Step 2: Drop Out to Root Shell

The system should display a menu with different boot options. Use the arrow keys to navigate to the option labeled root and press Enter.

The system should respond by giving you a command-line interface with a prompt.

Step 3: Remount the File System with Write-Permissions

Right now, your system only has read-only access to your system. That means it can look at the data, but cannot make any changes. But we need write-access to change the password, so we’ll need to remount the drive with the appropriate permissions.

At the prompt, type:

Press Enter. This should allow you to make changes to the data on the hard drive.

Step 4: Change the Password

At the prompt, type:

Substitute the name of the user for username, then press Enter. The system asks you to type a new UNIX password and then to retype it.

Once you’ve entered and confirmed the new password, reboot the system by entering the following:

Hit Enter, and your system should restart. Don’t press any keys, let the system come up to the login screen, and test to make sure the new password works.

Changing the Root Password in CentOS

Changing a password in CentOS is almost identical to changing it in Ubuntu.

Step 1: Access the Command Line (Terminal)

Right-click the desktop, then left-click Open in Terminal. Or, click Menu > Applications > Utilities > Terminal.

Step 2: Change the Password

At the prompt, type the following, then press Enter:

The system should prompt you to enter your existing password. Do so, then follow the prompts to enter and confirm a new root password.

Reset Root Password in CentOS

This is a similar process as in Ubuntu, with a couple of variations.

Step 1: Access Boot Menu

Restart the system, then tap the Esc key about once per second to launch the GRUB menu.

Step 2: Edit Boot Options

Use the arrows to highlight the version of Linux you boot into, then press e.

Use the arrows to highlight the line that starts with kernel or Linux.

Press E.

At the end of the line, add a space then type single. Press Enter, then boot into single-user mode by pressing Ctrl-X or B. (The system will display the command to use.)

Step 3: Remount the Drive

You should have a command line, and you’ll have root privileges. To enable read/write access on your hard drive, type the following:

Step 4: Changing the Password

Type the following:

Press Enter, and the system should prompt you to enter and confirm a new password.

Step 5: Restart

Type the following, pressing enter after each line:

Your system should restart. Confirm that your new password works by logging in.

If you already have access to your user account, resetting or changing your password in Linux is simple.

It can be more challenging if you’ve lost or forgotten a password, but with a little creative restarting and editing, you shouldn’t find it too hard.

Источник

How to Change The Root User Password in Linux?

As we already know root is a super user that can do anything in Linux system.

It’s similar to Administrator user in Windows.

root (Super User) can change any user account password in Linux.

Читайте также:  Скриншотер для linux mint

If you would like to change the root user password make sure you should become a root to perform it and you should have root privileges to perform it.

It can be done in two ways either passwd command or chpasswd command.

passwd command is native method to change the user password in Linux so, i also prefer to go with passwd command.

If you forgot the root password on CentOS/RHEL systems. Navigate to the following link to reset. To reset the forgotten root password on CentOS 6/RHEL 6 systems. To reset the forgotten root password on CentOS 7/RHEL 7 systems.

Type the passwd command alone in the terminal to change the root user password.

Enter the passwd command and followed by the user name to change the other users password.

When you use the passwd command, it will ask you to enter the password twice to change it.

For security reason you need to change your password frequently or at-least once in a month. Make sure you should use the hard and guess password (Alphabet Upper and Lower case letters, numbers and Special Characters (Symbols)) and your password length at-least 10-15 characters.

Method-1: Using passwd Command

The passwd command changes passwords for user accounts. passwd also changes the account or associated password validity period.

The user is first prompted for their old password, if one is present. This password is then encrypted and compared against the stored password.

The user has only one chance to enter the correct password. The superuser is permitted to bypass this step so that forgotten passwords may be changed.

After the password has been entered, password aging information is checked to see if the user is permitted to change the password at this time. If not, passwd refuses to change the password and exits.

The user is then prompted twice for a replacement password. The second entry is compared against the first and both are required to match in order for the password to be changed.

Syntax for passwd Command

To Change the root user password.

To change any other user password, type the corresponding username followed by the passwd command.

Use the below command to display the account status information.

The status information consists of 7 fields as follows

  • 2daygeek : Account login name (UserName)
  • PS : This field indicates whether the user account is locked or not. L locked password, NP User account doesn’t have password and PS Has a usable password.
  • 2019-01-13 : Date of the last password change.
  • 0 : Password expiry minimum age.
  • 99999 : Password expiry maximum age.
  • 7 : Password expiry warning period.
  • -1 : Inactivity period for the password

Run the below command to lock the user password.

Run the below command to check the user password. Yes, the password got locked which clearly showing LK in the below output.

Run the below command to unlock the user password.

The same has been verified by running the below command.

Delete a user’s password (make it empty). This is a quick way to disable a password for an account. It will set the named account passwordless.

The same has been verified by running the below command.

Method-2: Using chpasswd Command

The chpasswd command allow us to update passwords in batch mode. The chpasswd command reads a list of user name and password pairs from standard input and uses this information to update a group of existing users.

Make sure you should update the username and password in the following format.

UserName:Password

By default the passwords must be supplied in clear-text, and are encrypted by chpasswd. Also the password age will be updated, if present.

By default, passwords are encrypted by PAM. chpasswd first updates all the passwords in memory, and then commits all the changes to disk if no errors occurred for any user.

This command is intended to be used in a large system environment where many accounts are created at a single time.

There is no difference to update password for root or other users. We need to use the standard format for all users.

Run the following command to update the root user password using chpasswd command. Finally hit Ctrl+d to update the password and exit it.

Run the following command to update the daygeek user password using chpasswd command. Finally hit Ctrl+d to update the password and exit it.

Источник

Оцените статью