Cherry Servers

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:

Command Line
ssh your_username@your_server_ip

#Step 2: Verify Root or Sudo Privileges

Ensure you have root privileges by using the following command:

Command Line
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:
    Command Line
    sudo passwd username
    
  2. Enter the new password twice when prompted.
    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:

Outputpasswd: password updated successfully

or

Outputpasswd: 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.:
pwgen 16 1
  • Secure passwords (with -s). This forces the password to be more random and secure, ideal for critical accounts.:
pwgen -s 16 1
  • Include symbols (with -y). This creates a secure password of 16 characters with symbols included.:
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):
pwgen -B 16 1
  • Force numeric digits in the password (with -n). This ensures numeric digits are included:
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.

No results found for ""
Recent Searches
Navigate
Go
ESC
Exit
We use cookies to ensure seamless user experience for our website. Required cookies - technical, functional and analytical - are set automatically. Please accept the use of targeted cookies to ensure the best marketing experience for your user journey. You may revoke your consent at any time through our Cookie Policy.
build: 920a9a1ae.1622