Linux Change Password

How do I change my own password as well as the passwords of other users as required under Linux operating system without using GUI systems? How can I change or set user password on Linux operating systems?

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:

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements passwd command
Est. reading time Less than a minute


passwd {userName}


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:
$ passwd
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:
# passwd

WARNING! You can change root’s password only if you are logged in as the root user!

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.

Password example

  • 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

See how to generate a random password using the shell and/or mkpasswd command.

Storing password securely

Use personal password manager to store all passwords in a securely encrypted file. I recommend:

  1. gpass application.
  2. See a list of 7 apps that works under OS X/Linux and MS-Windows to store passwords.

Getting Help

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

See also

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 9 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
9 comments… add one
  • Prabhu Dec 8, 2010 @ 10:52

    1. Switch to root
    [user1@localhost ~]$ su –

    2. Change password for user2
    [root@localhost ~]# passwd user2
    Changing password for user user2.
    New password:
    BAD PASSWORD: it is WAY too short
    BAD PASSWORD: is a palindrome
    Retype new password:
    passwd: all authentication tokens updated successfully.
    [root@localhost ~]#

  • ameen Mar 9, 2011 @ 10:47

    wat can chang passward of root
    he can chang passwad of root

  • RambabuKella Feb 10, 2012 @ 21:52

    [root@localhost ~]# useradd speed
    [root@localhost ~]# passwd speed < rambabu
    > rambabu
    > EOF
    Changing password for user speed.
    New password: BAD PASSWORD: it is based on a dictionary word
    BAD PASSWORD: is too simple
    Retype new password: passwd: all authentication tokens updated successfully.
    [root@localhost ~]# useradd abcde
    [root@localhost ~]# echo “password” | passwd –stdin abcde
    Changing password for user abcde.
    passwd: all authentication tokens updated successfully.

  • err0rw0rse Apr 18, 2012 @ 4:51

    Hello ! i want to ask how i can change password for root if i forget my root pass and my linux is also need a login password . i forget login password for my user name ******* .how i can login to my workspace .

  • Mohit Shukla Jan 2, 2013 @ 8:35

    Login in single user mode and change the password. When you start the system just press the Ctrl+x for login in single user mode. And you will login there as root without password and you can change there your root password.

  • marimuthu Feb 21, 2013 @ 17:36

    booting the machine, at that time press “a” then click the space bar and type “s” then click enter first we check if it is enforcing mode or permissive mode by using this “getenforce” command if it is “enforcing” setenforce 0 then it will be change permissive mode . then “passwd –stdin root” type the password that’s it…………

  • Lawrence D. Noble, Sr. May 11, 2013 @ 19:05

    How about changing user I D and password not knowing either? Who am I requesting this info. from? Thanks ldn

  • eeezyy Oct 7, 2014 @ 9:15

    If you are sudo-user you can also change your root password, without logging in into root:

    > sudo su
    > passwd

  • Nick Mihai May 14, 2015 @ 7:46

    For the “issue”: BAD PASSWORD: it is based on a dictionary word

    Try this: (you should be ROOT)

    cd /etc/pam.d
    vi system-auth

    Comment all the three lines

    # password requisite try_first_pass retry=3
    # password sufficient md5 shadow nullok try_first_pass use_authtok
    # password required

    Add this line

    password sufficient /lib/security/$ISA/ nullok md5 shadow

    Make sure that you keep a login session open and test from another session.
    This way you will not lock yourself out.

    Good luck!
    On RHEL66 it works.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum