Ugacomp

How to change a user’s password in Linux

Where necessary, you may need to have access to a VPS server so you can follow how to implement the steps in this article.  You can get a cheaper VPS Server from Contabo with 4vCPU cores, 8GM RAM, and 32TB Bandwidth for less than $5.50 per month. Get this deal here now

Table of Contents

Cloud VPS S

$5.50 Monthly
  • 4 vCPU Cores | 8GB RAM

CLOUD VPS M

$15.50 Monthly
  • 6 vCPU Cores | 16GB RAM

CLOUD VPS L

$17.50 Monthly
  • 8 vCPU Cores | 24GB RAM

In this article, we’ll explore how to change a user’s password in Linux with clear and concise command examples.

Checking Current User Password

Before diving into changing passwords, it’s a good practice to verify the current password for the user. The following command allows you to check the password status for a specific user:

sudo passwd -S username

Replace “username” with the actual username you want to check. The output will display information about the user’s password, including its status.

Changing the Password

To change a user’s password, the passwd command comes to the rescue. Here’s the basic syntax:

sudo passwd username

After executing the command, you’ll be prompted to enter the new password twice for confirmation. Make sure to create a strong and secure password following your system’s password policy.

Forcing Password Expiry

In certain scenarios, administrators may want to force a user to change their password upon the next login for security reasons. The chage command helps achieve this:

sudo chage -d 0 username

This command sets the last password change date to the epoch, forcing the user to change their password at the next login.

Expiring Passwords

If you wish to set an expiration date for a user’s password, you can use the chage command again. The following example sets the maximum password age to 90 days:

sudo chage -M 90 username

Adjust the number according to your security policy.

Locking and Unlocking User Accounts

In some situations, you might need to temporarily lock a user account, perhaps due to security concerns. The passwd command can be used to lock and unlock an account:

  • To lock an account:
sudo passwd -l username
  • To unlock an account:
sudo passwd -u username

Hire us to handle what you want

Hire us through our Fiverr Profile and leave all the complicated & technical stuff to us. Here are some of the things we can do for you:

  • Website migration, troubleshooting, and maintenance.
  • Server & application deployment, scaling, troubleshooting, and maintenance
  • Deployment of Kubernetes, Docker, Cloudron, Ant Media, Apache, Nginx,  OpenVPN, cPanel, WHMCS, WordPress, and more
  • Everything you need on AWS, IBM Cloud, GCP, Azure, Oracle Cloud, Alibaba Cloud, Linode, Contabo, DigitalOcean, Ionos, Vultr, GoDaddy, HostGator, Namecheap, DreamHost, and more.
 

We will design, configure, deploy, or troubleshoot anything you want. Starting from $10, we will get your job done in the shortest time possible. Your payment is safe with Fiverr as we will only be paid once your project is completed.