Website Vidya
SecurityStep-by-Step Guide

How to Change User Password in Ubuntu

Learn how to change user password in ubuntu 24.04 for your own account or another user, enforce password expiry with chage, and manage policies.

RR
Rajesh RayLead Systems Educator
Published:
5 min read
PDF Cheat Sheet
How to Change User Password in Ubuntu
AI Executive SummaryWebsiteVidya AI

5 min read

Learn how to change user password in ubuntu 24.04 for your own account or another user, enforce password expiry with chage, and manage policies.

Key Highlights
  • Prerequisites and Supported Releases
  • Step 1: Changing Your Own Account Password
  • Step 2: Changing Another User's Password as Administrator (sudo)
Grounded in full engineering runbookWebsiteVidya AI Engine

User password management is the foundational pillar of Linux operating system security and access control.

Whether you are onboarding new team members, rotating credentials following a security audit, or resetting a forgotten account credential, knowing how to manipulate passwords safely is an essential administrative skill.

In Linux, user passwords are encrypted using state-of-the-art cryptographic hashing algorithms (such as yescrypt or SHA-512) and stored exclusively in the restricted /etc/shadow file.

The primary command-line utility for modifying password credentials across all UNIX-like systems is passwd.

Advertisement

In this tutorial, we demonstrate how to change user password in ubuntu for your own account, update passwords for other users using sudo, enforce password expiration schedules, and manage passwords in the desktop GUI.

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Before proceeding, ensure you have the following requirements satisfied:

Advertisement
  • A server or computer running Ubuntu 24.04 LTS or Ubuntu 22.04 LTS.
  • Access to a bash terminal shell.
  • Your current account password (when updating your own credentials).
  • sudo administrative privileges (when modifying passwords for other user accounts).

Step 1: Changing Your Own Account Password

Any unprivileged user account on Ubuntu can change their own password at any time without administrative permissions.

Simply invoke the passwd command without passing any arguments:

For security, Linux does not display asterisks or characters on screen while you type your password (known as password masking):

# Invoke passwd command:
passwd

# Terminal interactive prompt flow:
# Current password: [Enter your existing password]
# New password: [Enter your new password]
# Retype new password: [Confirm your new password]
# passwd: password updated successfully

Step 2: Changing Another User's Password as Administrator (sudo)

System administrators frequently need to reset passwords for colleagues who have forgotten their credentials or locked themselves out.

Advertisement

When executed with sudo, the passwd command accepts a target username as an argument.

Unlike standard users, an administrator executing with sudo is never prompted for the user's existing password:

Execute the following command to update a user's password:

# Update password for user 'john':
sudo passwd john

# Terminal interactive prompt flow:
# New password: [Enter new password for john]
# Retype new password: [Confirm new password]
# passwd: password updated successfully

Step 3: Forcing a User to Change Their Password on Next Login

When an administrator assigns a temporary password to a user account, security best practices dictate that the user should be forced to replace it immediately upon logging in.

Use the passwd utility with the -e (expire) option to expire the password immediately:

The next time the user establishes an SSH or console session, Ubuntu halts access until a new password is created:

# Force password expiration for user 'john':
sudo passwd -e john
# Output: passwd: password expiry information changed.

# When 'john' logs in via SSH or terminal:
# WARNING: Your password has expired.
# You must change your password now and login again!
# Current password: 
# New password: 
# Retype new password:

Step 4: Managing Password Expiration Policies with chage

Enterprise compliance frameworks (such as SOC 2, HIPAA, or PCI-DSS) require regular credential rotation policies.

The chage (change aging) command manages password expiration dates, warning periods, and inactivity lockouts.

Inspect an account's active aging parameters using chage -l:

Configure a 90-day password rotation policy with a 7-day warning period:

# Inspect active password aging details:
sudo chage -l john
# Output:
# Last password change                    : Jul 15, 2024
# Password expires                        : never
# Password inactive                       : never
# Account expires                         : never
# Minimum number of days between password change: 0
# Maximum number of days between password change: 99999
# Number of days of warning before password expires: 7

# Enforce 90-day password expiration (-M) and 7-day warning (-W):
sudo chage -M 90 -W 7 john

Step 5: Changing User Passwords in Ubuntu Desktop (GUI)

For workstation users running the GNOME desktop environment on Ubuntu, passwords can be updated through the Settings panel:

Follow these graphical steps to modify credentials:

Step NumberDesktop NavigationAction Required
Step 1Open SettingsClick the system status menu in the top-right corner and select Settings
Step 2Navigate to System -> UsersView all local user accounts configured on the computer
Step 3Unlock Administrative ModeClick Unlock in the header and enter your administrative password
Step 4Select Target AccountClick on the account whose password you wish to modify
Step 5Click PasswordChoose 'Set a password now' and enter the new credential, or select 'Allow user to set a password when they next login'

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

passwd: Authentication token manipulation error

Cause: The filesystem is mounted read-only, /etc/shadow has corrupt permissions, or disk space is 100% full.

Resolution: Check disk space with df -h and ensure /etc/shadow is writable by root with ls -la /etc/shadow.

df -h && sudo mount -o remount,rw /

passwd: You may not view or modify password information for username

Cause: Attempting to change another user's password without prepending sudo.

Resolution: Prepend sudo to elevate privileges: sudo passwd username.

sudo passwd username

Password rejected: BAD PASSWORD: The password is shorter than 8 characters

Cause: Ubuntu's PAM password quality module (pam_pwquality) rejected the proposed password for insufficient complexity.

Resolution: Choose a stronger password containing uppercase letters, lowercase letters, numbers, and symbols, or override as root with sudo passwd.

sudo passwd username

Security Best Practices and Hardening

Never share passwords across user accounts; create dedicated individual logins with personal sudo access.

Enforce minimum password length and complexity requirements by editing /etc/security/pwquality.conf (e.g. minlen = 12).

Monitor unauthorized password modification attempts by inspecting security events in /var/log/auth.log.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

4 FAQs
No. Linux stores passwords as irreversible cryptographic hashes (e.g., using yescrypt or SHA-512) inside /etc/shadow. Administrators can overwrite or reset a password, but cannot reverse-engineer or reveal the original plaintext.
Run sudo passwd -l username. This prepends an exclamation point (!) to the account's password hash in /etc/shadow, immediately blocking password-based authentication.
Run sudo passwd -u username. This removes the lock prefix and restores the user's password access.
Yes. You can pipe credentials using the chpasswd utility: echo 'username:NewPassword123' | sudo chpasswd. Ensure your shell history is cleared afterward to prevent leaking plaintext credentials.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout