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.

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.
- Prerequisites and Supported Releases
- Step 1: Changing Your Own Account Password
- Step 2: Changing Another User's Password as Administrator (sudo)
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.
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.
Complete Linux administrator guide on managing account passwords on Ubuntu 24.04 LTS (Noble Numbat) and 22.04 LTS. Explains changing your own account password with passwd, changing other users' passwords as root/sudo, enforcing password expiration policies using chage, forcing password updates upon next login, and managing passwords graphically on Ubuntu Desktop.
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:
- 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).
sudoadministrative 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.
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 Number | Desktop Navigation | Action Required |
|---|---|---|
| Step 1 | Open Settings | Click the system status menu in the top-right corner and select Settings |
| Step 2 | Navigate to System -> Users | View all local user accounts configured on the computer |
| Step 3 | Unlock Administrative Mode | Click Unlock in the header and enter your administrative password |
| Step 4 | Select Target Account | Click on the account whose password you wish to modify |
| Step 5 | Click Password | Choose '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.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
- How to Add a User to Sudoers in Ubuntu — Configure administrative privileges and password policies for sudo accounts.
- How to Create a Sudo User on Ubuntu — Create and provision new user accounts with initial passwords.
- How to Change Root Password in Ubuntu Linux — Manage and reset superuser credentials on Ubuntu.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
yescrypt or SHA-512) inside /etc/shadow. Administrators can overwrite or reset a password, but cannot reverse-engineer or reveal the original plaintext.sudo passwd -l username. This prepends an exclamation point (!) to the account's password hash in /etc/shadow, immediately blocking password-based authentication.sudo passwd -u username. This removes the lock prefix and restores the user's password access.chpasswd utility: echo 'username:NewPassword123' | sudo chpasswd. Ensure your shell history is cleared afterward to prevent leaking plaintext credentials.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
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.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides

Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!