You can use the passwd command to change your password, and, as a system administrator, change the password of the root account, or another user in your Linux system. The syntax is as follows:
|Time||Less than a minute|
passwd [option] userNameHere
Task: Linux Change Your Own Password
Login using the ssh client or open a command-line terminal (select Applications > Accessories > Terminal), than type the following command:
First, the user is prompted for their current password. If the current password is correctly typed, a new password is requested. The new password must be entered twice to avoid typing errors. Running passwd command with no arguments will allow you to change your own password.
Task: Linux Change root’s User Password
To change root’s password, you must first login as root user or use sudo / su command to obtain root’s credentials. To become the root user, enter:
$ su -l
$ sudo -s
To change root’s password, enter:
Task: Linux Change Another User’s Password
To change the password of another user, login as root and type:
# passwd userNameHere
# passwd tom
# passwd jerry
A note about protecting your password
Your password unlocks your account and all data on Linux. So you need to protect your password. Here are some simple tips:
- Please do not write down your password. You need to memorize it.
- Do not use the same password for all your accounts including ssh, git, file and email servers. Use unrelated passwords for systems controlled by different organizations.
- Do not share or give your password, in particular to some one claiming to be from computer IT support department or a vendor.
- Make sure no one watch you enter your password.
- Change password periodically.
- Choose a hard-to-guess password. Avoid using the following passwords:
- Simple words or words that you’d find in a dictionary.
- Do not use your name including that of a spouse, child, pet, city and so on.
- Do not use your birhdate, ssn/pan, phone/mobile number and driving license numbers.
- A good password consists of:
- Mixture of upper and lower case letters, as well as digits or punctuation.
- At least 8 characters long.
- Passphrase : I love Pizza and Beer.
- Take the first letter of each word in a passphrase – I l P a B
- Add digits: I2 l P a9B
- Add special character: I2+l P&a9B
- Add other characters: qI2+lUP&a9Bw
Storing password securely
Use personal password manager to store all passwords in a securely encrypted file. I recommend:
- gpass application.
- See a list of 7 apps that works under OS X/Linux and MS-Windows to store passwords.
Anytime you need assistance with Linux passwd command-line, turn to the man page first. It will give you detailed information, parameters and switches for passwd command. For example, man passwd opens the man page for the passwd command:
$ man passwd
$ man 5 passwd
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
|Category||List of Unix and Linux commands|
|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|