Skip to content

A Comprehensive Guide: How to Use Passwd Command on Linux with Examples

The passwd command is an essential utility tool for managing user passwords in the Linux operating system. It allows users to change their passwords, reset passwords for other users, and configure password expiration and aging parameters. In this comprehensive guide, we will explore the various functionalities of the passwd command and provide step-by-step examples to help you effectively use this command on your Linux system.

Understanding the Basics of Passwd Command

Before delving into the advanced features of the passwd command, it’s important to have a clear understanding of what exactly this command does and why it is crucial in a Linux environment.

In a Linux environment, the passwd command is a powerful tool that allows users to change their login passwords. It provides a simple and efficient way to maintain the security of user accounts, ensuring that only authorized individuals have access to sensitive information.

When a user logs into a Linux system, they are required to enter their username and password. The passwd command allows users to change their password at any time, providing an added layer of security. By regularly updating passwords, users can help prevent unauthorized access to their accounts and protect their personal information.

What is Passwd Command?

The passwd command is a command-line tool that allows Linux users to change their login passwords. It is an integral part of the Linux system’s security infrastructure, ensuring that user accounts remain secure and protected from unauthorized access.

When executed, the passwd command prompts the user to enter their current password and then enter a new password. The new password must meet certain criteria, such as a minimum length and a combination of letters, numbers, and special characters. Once the new password is entered and confirmed, it is encrypted and stored securely in the system’s password file.

It’s important to note that the passwd command can only be executed by the root user or by users with sudo privileges. This restriction ensures that only authorized individuals have the ability to change passwords and maintain the security of the system.

Importance of Passwd Command in Linux

The passwd command plays a vital role in ensuring the security of the Linux system. By regularly changing passwords and implementing password expiration and aging policies, system administrators can reduce the risk of unauthorized access, data breaches, and other security vulnerabilities.

One of the key benefits of the passwd command is its ability to enforce password complexity requirements. By setting minimum password length and requiring a combination of uppercase and lowercase letters, numbers, and special characters, system administrators can ensure that passwords are strong and resistant to brute-force attacks.

In addition to enforcing password complexity, the passwd command also allows system administrators to set password expiration dates. By setting a password expiration policy, users are prompted to change their passwords at regular intervals, ensuring that passwords are regularly updated and reducing the risk of compromised accounts.

Furthermore, the passwd command provides system administrators with the ability to disable user accounts temporarily or permanently. This feature is particularly useful in situations where a user’s account has been compromised or when an employee leaves the organization. By disabling the account, system administrators can prevent unauthorized access and maintain the overall security of the system.

Now that we understand the significance of the passwd command, let’s dive deeper into its usage and explore the various functionalities it offers.

Diving Deeper into Passwd Command

To effectively use the passwd command, it is important to familiarize yourself with its syntax and the options available.

The passwd command is a powerful tool that allows users to change their passwords on a Unix-like operating system. It provides a secure and convenient way to update your password without the need for administrative privileges.

Syntax of Passwd Command

The syntax of the passwd command is straightforward:

passwd [options] [username]

The optional username argument allows you to change the password of a specific user. If no username is provided, the password for the current user will be changed.

For example, if you want to change the password for the user “john”, you would use the following command:

passwd john

This would prompt you to enter the new password for the user “john”.

Options Available in Passwd Command

The passwd command offers several options that allow for greater flexibility and control. Some commonly used options include:

  • -l: Locks the specified user account, preventing login.
  • -u: Unlocks a previously locked user account.
  • -d: Sets the user’s password to an empty string, effectively disabling password-based login.

These options can be combined with the username argument to perform specific actions on user accounts. For example, to lock the user account “john”, you would use the following command:

passwd -l john

This would prevent the user “john” from logging in until the account is unlocked using the -u option.

It is important to note that some options may require administrative privileges to execute. Make sure you have the necessary permissions before attempting to use these options.

These are just a few examples of the available options. The passwd command provides a wide range of options to suit different needs. To explore all the options and their descriptions, you can refer to the passwd command’s manual page. The manual page provides detailed information on each option, including their usage and any additional considerations.

By understanding the syntax and options of the passwd command, you can effectively manage user passwords and enhance the security of your system. Whether you need to change a password, lock an account, or disable password-based login, the passwd command has you covered.

Changing User Passwords with Passwd

One of the primary functions of the passwd command is to allow users to change their own passwords or reset passwords for other users.

Changing your own password is a simple process. By executing the passwd command without providing any additional arguments, you can initiate the password change:


Upon executing the command, you will be prompted to enter your current password. Once you have done so, you will then be prompted to input a new password. Follow the on-screen instructions to complete the process.

Changing Other User’s Password as Root

As a system administrator, you may need to reset passwords for other users on your Linux system. This can be done using the passwd command, but with the appropriate privileges.

To change another user’s password as the root user, follow these steps:

  1. Open a terminal and execute the following command:
sudo passwd [username]

Replace [username] with the actual username of the user whose password you wish to change. This command will prompt you to enter the root password.

  1. After entering the root password, you will be prompted to input a new password for the specified user.

By following these steps, you can successfully change the password for another user on your Linux system.

It is important to note that changing passwords should be done with caution and only with proper authorization. As a system administrator, it is your responsibility to ensure the security and integrity of your system.

Managing Password Expiration and Aging

Another important aspect of user account management is implementing password expiration and aging policies to ensure the security of your Linux system.

Setting Password Expiration Date

The passwd command allows you to set an expiration date for a user’s password. This ensures that users are required to change their password periodically. To set a password expiration date, use the following command:

sudo passwd -e [username]

Replace [username] with the username of the user you want to set an expiration date for. Once an expiration date is set, the user will be prompted to change their password upon their next login.

Configuring Password Aging Parameters

In addition to setting an expiration date, you can also configure various password aging parameters using the passwd command. These parameters control settings such as the minimum and maximum password age, password warning period, and more.

To configure password aging parameters, use the chage command followed by the username:

sudo chage [username]

This command will open a text editor where you can make the necessary edits to the password aging parameters. Follow the instructions within the text editor to specify the desired values.

Troubleshooting Common Passwd Command Issues

While using the passwd command, you may encounter certain issues that require troubleshooting to resolve. Let’s explore two common issues and their solutions.

Dealing with Permission Denied Error

If you receive a “Permission denied” error when attempting to change another user’s password, ensure that you are executing the command as the root user or using the sudo command. Only users with sufficient privileges can change other users’ passwords using the passwd command.

Resolving Authentication Token Manipulation Error

The “Authentication token manipulation” error can occur when the system is unable to update the user’s password due to various reasons, such as insufficient disk space or file system issues. If you encounter this error, try freeing up disk space or resolving any underlying file system issues. Additionally, make sure you are entering the correct current password when prompted.


The passwd command is an essential tool for managing user passwords in a Linux environment. By understanding its various functionalities and options, you can effectively change passwords, configure password expiration and aging policies, and troubleshoot common issues. By implementing best practices and promoting password security, you can enhance the overall security of your Linux system and protect sensitive data from unauthorized access.

Now that you have a comprehensive understanding of how to use the passwd command on a Linux system, you can confidently manage user passwords and ensure a secure computing environment.

Last Updated on January 2, 2024 by admin

Share this post on social

Copyright 2022 All rights reserved. No part of this website may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the copyright owner.