• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

passwd command in Linux with Examples

368

Password command

Password command is used to change the password for user accounts. User may change the password for their own account while the super user (root) may change the password for any account. Using this command, the validity period of the password can also be changed.

Syntax

passwd < options> < User-name>

Options
-a, --all : It is used only with -S and shows status of all users.
-d, --delete : Deletes a user' s password then it makes empty.
-l, --lock : Locks password entry for rename.
-f, --force : Force the user to change password at the next login by expiring the password for name.
-S, --status : To report the password status on the named account. It contains 7 fields in the status information
-u, --unlock : unlock the password of named account.

Change Password of System Users

passwd command is used to change the password of system user. Changing Password from root user

Example

[root@linuxhelp ~]# passwd user1 
Changing password for user user1.
Changing password for user1.
(current) UNIX password:
New password:
Retype new password:
Passwd: all authentication tokens updated successfully.

Changing password from its own user

Example

[user1@linuxhelp ~]$passwd 
Changing password for user user1.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Display Password Status Information

passwd command is used to view the password status information about the users by using &ndash S option.

Example

[root@linuxhelp ~]# passwd -S user1 
user1 PS 2016-02-03 0 99999 7 -1 (Password set, SHA512 crypt.)

Removing Password of a User

To remove the Password of a user, the password command with option ‘ d’ is used.

Example

[root@linuxhelp ~]# passwd -d user1 
Removing password for user user1.
passwd: Success
     
[root@linuxhelp ~]# passwd -S user1 
user1 NP 2016-02-03 0 99999 7 -1 (Empty password.)     

Set Password Expiry Immediately

passwd command is used to set the password expiry immediately for a user using -e option. This will force the user to change the password in the next login.

Example

[root@linuxhelp ~]#passwd  -e  user2 
Expiring password for user user2.
passwd: Success
[root@linuxhelp ~]# passwd  -S  user2 
user2 PS 1969-12-31 0 99999 7 -1 (Password set, SHA512 crypt.)

Example

[user1@linuxhelp ~]# ssh user2@192.168.7.13 -p24865 
user2@192.168.7.13' s password:
You are required to change your password immediately (root enforced)
WARNING: Your password has expired.
You must change your password now and login again!
Changing password for user user2.
Changing password for user2.
(current) UNIX password:

Lock the password of System User

passwd command is used to lock the password for a user using -l option.

Example

[root@linuxhelp ~]# passwd -l user1 
Locking password for user user1.
passwd: Success
[root@linuxhelp ~]# passwd -S user1 
user1 LK 1969-12-31 0 99999 7 -1 (Password locked.)

Unlock User’ s Password

passwd command is used to unlock the user' s password for a user using -u option.

Example

[root@linuxhelp ~]# passwd -u user1 
Unlocking password for user user1.
passwd: Warning: unlocked password would be empty.
passwd: Unsafe operation (use -f to force)
         
[root@linuxhelp ~]# passwd -f user1 
Changing password for user user1.
New password:
BAD PASSWORD: it is WAY too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.

Set the inactive days for a user

passwd command is used to set the inactive days for a user using -i option.

Example

[root@linuxhelp ~]# passwd  -i  7  user1 
Adjusting aging data for user user1.
passwd: Success
[root@linuxhelp ~]# passwd -S user1   
user1 PS 2016-02-03 0 99999 7 7 (Password set, SHA512 crypt.)

Set Minimum Days to Change Password

passwd command is used to set the minimum days to change password for a user using -n option.

Example

[root@linuxhelp ~]# passwd -n 60 user1 
Adjusting aging data for user user1.
passwd: Success
[root@linuxhelp ~]# passwd -S user1 
user1 PS 2016-02-03 60 99999 7 7 (Password set, SHA512 crypt.)

To Set Warning days before password expiry

passwd command is used to set the warning days before user' s password expire for a user using -w option.

Example

[root@linuxhelp ~]# passwd -w 10 user1 
Adjusting aging data for user user1.
passwd: Success
[root@linuxhelp ~]# passwd -S user1 
user1 PS 2016-02-03 60 99999 10 7 (Password set, SHA512 crypt.)

Tags:
benjamin
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

How to display the account status information using the "passwd" command in Linux?

A

You can use the following syntax to display the account status information using the "passwd" command in Linux. For Ex: "passwd -S username".

Q

How to delete an Account password using the "passwd" command in Linux?

A

You can use the option of "-d" with "passwd" command to delete an Account password in Linux. For Ex: "passwd -d username"

Q

How do I set Immediately expire the account password using "passwd" command?

A

You can use the option of "-e" with "passwd" command to set Immediately expire the account password. For syntax: "passwd -e username".

Q

How to know the entire information and options to be available for "passwd" command?

A

You can use the option of "--help" (or) "man" page of "passwd" command to know the entire information and options to be available for "passwd" command. For Syntax: "passwd --help" (or) "man passwd".

Q

How to set number of days after password expiration when an account becomes disabled using rhe "passwd" command?

A

You can use the option of "-i" with "passwd" command to set number of days after password expiration when an account becomes disabled. For Ex: "passwd -i 5"

Related Tutorials in passwd command in Linux with Examples

Related Tutorials in passwd command in Linux with Examples

How to reset Root user password from boot on Oracle Linux 8.5
How to reset Root user password from boot on Oracle Linux 8.5
Oct 1, 2022
How to Setup Password Authentication with Apache in Ubuntu
How to Setup Password Authentication with Apache in Ubuntu
Nov 24, 2016
passwd command in Linux with Examples
passwd command in Linux with Examples
Mar 22, 2016
How To Reset MariaDB root Login Password
How To Reset MariaDB root Login Password
Aug 29, 2019
How to reset Root user password from boot on Rocky Linux 8.6
How to reset Root user password from boot on Rocky Linux 8.6
May 11, 2023

Related Forums in passwd command in Linux with Examples

Related Forums in passwd command in Linux with Examples

Ubuntu
mason class=
Passwd: You may not view or modify password information for root On Ubuntu 19.04
May 27, 2019
Linux
charmi class=
How to change password of multiple users at a single command
Apr 22, 2019
Ubuntu
caden class=
How to set a root password in Ubuntu 18.10
Apr 9, 2019
Ubuntu
isaac class=
How to reset the password of the log in user In Ubuntu 18.10
Apr 15, 2019
Ubuntu
mason class=
How to login to Ubuntu 18.04 without a password
Dec 21, 2018
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ganesh Konka ?
Zentya 6.1 http proxy configuration

please send link for creating zentyal 6.1 for http proxy and firewall as gateway.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.