# How to Change a User Password on a Linux Server

While working on a Linux server, you may have the need to change a user’s password. This guide will provide step-by-step instructions for how to change the password of any user, including the root user, using root access or sudo privileges.

## Instructions to Change a User Password on a Linux Server
### Step 1: Log in to Your Server
Access your server using SSH from your terminal. 
   
Use the command below to connect, replacing "*your_username*" with your actual username, and "*your_server_ip*" with your server's IP address:
   ```bash command
   ssh your_username@your_server_ip
   ```
### Step 2: Verify Root or Sudo Privileges
Ensure you have root privileges by using the following command:
```bash command
sudo -i
```
### Step 3: Change the User Password
1. Run the *passwd* command to change the password for a specific user. Replace "*username*" with the target user:
	```bash command
	sudo passwd username
	```
2. Enter the new password twice when prompted.
	```bash output
	[root@cherryservers-kb ~]# sudo passwd
	Changing password for user root.
	New password:
	Retype new password:
	```
### Step 4: Verify Password Change
After successfully updating the password, you should see a confirmation message:
```bash output
passwd: password updated successfully
```
or
```bash output
passwd: all authentication tokens updated successfully
```

Ensure that during this process you used a secure, airtight password that is not possible to guess or brute force. For assistance, you may wish to use pwgen.

## How to Generate Secure Passwords Using pwgen
pwgen is a handy utility to generate strong, random passwords on Linux. Here are some useful options you can use with pwgen to create highly secure passwords:
- Basic password generation. This generates a 16-character password. You can adjust the number 16 to a different length, while 1 specifies how many passwords to generate.:
```bash comnmand
pwgen 16 1
```
- Secure passwords (with -s). This forces the password to be more random and secure, ideal for critical accounts.:
```bash comnmand
pwgen -s 16 1
```
- Include symbols (with -y). This creates a secure password of 16 characters with symbols included.:
```bash comnmand
pwgen -sy 16 1
```
- Avoid ambiguous characters (with -B). This generates passwords that avoids characters that could be mistaken for each other (like O and 0):
```bash comnmand
pwgen -B 16 1
```
- Force numeric digits in the password (with -n). This ensures numeric digits are included:
```bash comnmand
pwgen -n 16 1
```
in short:
- -s: Stronger, more random passwords.
- -y: Include symbols in the password.
- -B: Avoid ambiguous characters.
- -n: Ensure the password includes numeric digits.

Using these steps and tips will help ensure your server is secured with strong and unique passwords for each user.