• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

passwd command in Linux with Examples

{{postValue.id}}

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
{{postCtrl.cmtErrMsg}}

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"

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 David Lopez Guillen ?
Ayuda urgente instale SSL para servidor Opensuse y ahora no funciona tengo servicio web

hola segui este tutorial para tener un certificado ssl y ahora no se ve mi app en la red, espero alguien pueda ayudarme, tengo M9oodle en3.5 en un servidor open suse y ahora no funciona por favor ayuda.

https://www.linuxhelp.com/how-to-create-ssl-certificate-in-opensuse

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.