You need to use the passwd command to changes the user’s password.
Rules for changing passwords for user accounts
- A normal user may only change the password for his/her own account.
- The superuser (root user) may change the password for any account or specific account.
- The passwd command also changes the account or associated password validity period.
First, login as the root user. Use sudo -s or su - command to login as root. To change password of specific user account, use the following syntax:
passwd userNameHere
To change the password for user called vivek, enter:
# passwd vivek
Sample outputs:
# passwd -S userNameHere
# passwd -S vivek
Sample outputs:
vivek P 05/05/2012 0 99999 7 -1
The status information consists of 7 fields as follows:
- vivek : Account login name (username)
- P : This field indicates if the user account has a locked password (L), has no password (NP), or has a usable password (P)
- 05/05/2012 : Date of the last password change.
- 0 : Password expiry minimum age
- 99999 : Password expiry maximum age.
- 7 : Password expiry warning period.
- -1 : Inactivity period for the password (see chage command for more information).
To get more info about password aging for a specific user called vivek, enter:
# chage -l vivek
🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 7 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
passwd
U will prompted for password and U can change it! If you are doing it for somebody else, U need to be root!
Tried same, below is output, didn’t got “PS”
[root@externvlab1280 ~]# passwd -S bhushan
bhushan PS 2012-10-11 10 90 7 -1 (Password set, SHA512 crypt.)
itsssssssssss helps me at a valid time
t4nks.
Can’t set the password. I need an example. Can you help?
$ passwd
this will prompt u to input the current password and then prompt u to change to the new password
how to disable user to change another user password?