Linux Set or Change User Password

How do I set or change Linux system password for any user account? How can I change user password on Linux operating system using the command-line options?

Both Linux and UNIX-like operating systems use the passwd command to change user password. The passwd is used to update a users authentication token (password) stored in /etc/shadow file. The passwd change passwords for user and group accounts. A normal user may only change the password for his/her own account, the super user (or root) may change the password for any account. The administrator of a group may change the password for the group. passwd also changes account information, such as the full name of the user, user login shell, or password expiry date and interval.

Linux Set User Password

Type following passwd command to change your own password:
$ passwd
Sample Outputs:

Changing password for vivek
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

The user is first prompted for his/her old password if one is present. This password is then encrypted and compared against the stored password. The user has only one chance to enter the correct password. The super user is permitted to bypass this step so that forgotten passwords may be changed. A new password is tested for complexity. As a general guideline, passwords should consist of 10 to 20 characters including one or more from each of following sets:

  1. Lower case alphabetics
  2. Upper case alphabetics
  3. Digits 0 thru 9
  4. Punctuation marks/spacial characters

Linux change password for other user account

You need to login as the root user, type the following command to change password for user vivek:
# passwd vivek
$ sudo passwd vivek
Sample putput:

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully


  • vivek – is username or account name.

Passwords do not display to the screen when you enter them. For example:

Linux changing user password using passwd

Linux Change Group Password

When the -g option is used, the password for the named group is changed. In this example, change password for group sales:
# passwd -g sales
The current group password is not prompted for. The -r option is used with the -g option to remove the current password from the named group. This allows group access to all members. The -R option is used with the -g option to restrict the named group for all users.

Changing user passwords on Linux

As a Linux system administrator (sysadmin) you can change password for any users on your server. To change a password on behalf of a user:

  1. First sign on or “su” or “sudo” to the “root” account on Linux, run: sudo -i
  2. Then type, passwd tom to change a password for tom user
  3. The system will prompt you to enter a password twice


The passwd command line utility is used to update or change user’s password. The encrypted password is stored in /etc/shadow file and account information is in /etc/passwd file. To see all user account try grep command or cat command as follows:
cat /etc/passwd
grep '^userNameHere' /etc/passwd
grep '^tom' /etc/passwd

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig 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
72 comments… add one
  • Nimisha Mar 21, 2014 @ 15:41


  • sajan Jun 26, 2014 @ 14:12

    How to create a password and change password of a user account in VPN.

  • Albin Troja Oct 11, 2014 @ 19:32

    help help
    i have password changed, and i have logged without problems, after login is this problem

    this is from root after login

    login as: root
    root@‘s password:
    Last login: Sun Oct 12 01:24:10 2014 from che…123456789ipad01.3.g……s….at
    Changing finger information for root.
    Name [Albin Troja]:
    Office [albabin@l….de]:
    Office Phone [0676123456789]:
    Home Phone [0316010101010]:

    and closed automatically, please help me.

  • sadegh Oct 15, 2014 @ 16:42

    Hi. hw can I write a linux over older linux??

  • mahdi Dec 12, 2014 @ 5:41

    i have problem with root mode when i log in and enter password the Linux say
    what should i do and how the password i found it and change it .??

  • Robert Apr 1, 2015 @ 23:41

    Cool tutorial, but how to set a superuser password?

  • Jake Apr 4, 2015 @ 3:17

    I have no password set, so what do I put in when it asks for what my password is now? And it won’t even let me type in the space provided!

    • centos7-adm Mar 12, 2016 @ 17:13

      @Jake, to set a password for a user when you forgot to do type:
      passwd heretheusername , then it will ask to set a password (confirm it by re-typing)

  • Kanakaraj Feb 25, 2016 @ 5:08

    how to set default password for user in Linux ??

  • ajay mewada Feb 29, 2016 @ 10:25

    i have to set password for terminal in linux when open terminal through graphically or by shortcut key please give me suggession for this and do this by command

  • centos7-adm Mar 12, 2016 @ 17:24

    A nice simple article Vivek, but the problem as it seems are the ppl who can’t read :) Maybe you should ask if you need to chew also for them when they want to eat, joking.

  • karkadan Apr 5, 2016 @ 12:53

    i forgot the password of my Linux vmuser. what can i do ?
    thank you :)

  • Richmond Nov 23, 2016 @ 16:23

    wonderful page. It helped me beautifully.

  • Matt Dec 29, 2016 @ 16:13

    i did try this passwd command and it said token error. PLZ help me . i just set up my linux comp. too. and i dont want my password to be set to what they gave me

  • Mohan Oct 6, 2017 @ 8:07


    I have just added one user using command useradd. But when i try to set the password its asking for current password.Please help. Thanks

  • chrismint Oct 3, 2020 @ 10:28

    Thanks for the tutorial, really helped me a lot !

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.