≡ Menu

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:



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. man passwd
    $ man 5 passwd

    See also
    Share this tutorial on:
{ 9 comments… add one }
  • PrabhuDecember 8, 2010, 10:52 am

    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 ~]#

  • ameenMarch 9, 2011, 10:47 am

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

  • RambabuKellaFebruary 10, 2012, 9:52 pm

    [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.

  • err0rw0rseApril 18, 2012, 4:51 am

    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 ShuklaJanuary 2, 2013, 8:35 am

    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.

  • marimuthuFebruary 21, 2013, 5:36 pm

    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, 7:05 pm

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

  • eeezyyOctober 7, 2014, 9:15 am

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

    > sudo su
    > passwd

  • Nick MihaiMay 14, 2015, 7:46 am

    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 pam_cracklib.so try_first_pass retry=3
    # password sufficient pam_unix.so md5 shadow nullok try_first_pass use_authtok
    # password required pam_deny.so

    Add this line

    password sufficient /lib/security/$ISA/pam_unix.so 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.

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , , , , , , , , , , ,