How to Change Linux Password Quickly and Easily
Tags: webdev, kalilinux, tutorial, devops
Published: 2023-05-27 08:52:51

Changing passwords in Linux is an easy process that may be completed in a few steps. It is essential to change your password on a frequent basis to ensure the security of your system. This article will show you how to Change password in Linux, as well as some recommendations and recommended practises for creating strong passwords. By following these procedures, you can keep your PC secure and protect yourself from dangerous threats.

## Change the Password for a Single User in Linux

To change a password in Linux, you can follow these steps:

- Open a terminal: You can open a terminal by pressing Ctrl + Alt + T or by searching for “Terminal” in the applications menu.

- Type the following command and press Enter to change the password for your own user account:

  `passwd`

If you have administrative privileges and want to change the password for another user, you can run the following command instead (replace <username> with the actual username):

`   sudo passwd <username>
`
You’ll be prompted to enter your current password (or the root password if using sudo) for authentication.

After successful authentication, you’ll be prompted to enter a new password. Type the new password and press Enter. 

Note that the password will not be displayed on the screen while typing. You’ll be prompted to re-enter the new password for confirmation. 

Type the password again and press Enter.

If the new password meets the system’s requirements, it will be successfully changed, and you should see a confirmation message.
Change Your Linux Password

That’s it! The password for the specified user will be updated. Make sure to remember your new password, or store it securely.

## Change Linux Password for Multiple Users

To change passwords for multiple users in Linux, you can use a script or command to automate the process. Here’s an example of how you can achieve this using a shell script:

Open a text editor, such as Nano or Vim, to create a new shell script file. For example, you can use the following command to create a file called changepasswords.sh:

```
   nano changepasswords.sh

```
In the text editor, add the following content to the file:
   

```
#!/bin/bash

   # List of usernames to change passwords for
   users=("user1" "user2" "user3")

   # Loop through the list of users and change passwords
   for user in "${users[@]}"
   do
       echo "Changing password for user: $user"
       sudo passwd $user
   done
```
In the users array, replace "user1", "user2", "user3", etc., with the actual usernames for which you want to change passwords. You can add as many usernames as needed.

Save the file and exit the text editor.
Make the script file executable by running the following command:

```
`   chmod +x changepasswords.sh

```
`Execute the script by running the following command:

```
   ./changepasswords.sh

```
You’ll be prompted to enter the root password (or use sudo if required) to run the script with administrative privileges.

The script will loop through the list of users and prompt you to enter new passwords for each user. Follow the prompts and enter the desired passwords. The script will change the passwords for all the specified users.

By using this script, you can easily change passwords for multiple users in one go. Remember to use it responsibly and protect the script file with appropriate permissions, as it has administrative privileges.

[Source](https://hackreveal.com/how-to-change-linux-password-quickly-and-easily/)