Change the Password in UNIX

How do I change the password in UNIX? In Unix operating system, how do I change my password?

Introduction – To modify a user’s password or your own password in UNIX-like oeprating system use the passwd command command. To safeguard your Unix user/root password, you should change your password regularly.

How to change the password in UNIX

The procedure for changing the password of root or any user is as follows:

  1. First, log in to the UNIX server using ssh or console
  2. Open a shell prompt and type the passwd command to change root or any user’s password in UNIX
  3. The actual command to change the password for root user on UNIX is sudo passwd root
  4. To change your own password on Unix run passwd

How to change the Password in UNIX

Open the terminal and then type the passwd command entering the new password, the characters entered do not display on screen, in order to avoid the password being seen by a passer-by. The passwd command prompts for the new password twice in order to detect any typing errors. The encrypted password is stored in /etc/shadow file.

In Unix, how do I change my password

UNIX Task: Change Any Users Password

Login as the root user and type the command:
# passwd userName
# passwd vivek
# passwd tom

Sample outputs:

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

UNIX Task: Change Your Own Password

Simply type the passwd command:
$ passwd
Sample outputs:

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

UNIX Task: Change root User Password

Log in as root user and run:
# passwd


The passwd command changes the user’s password. If no user is specified, the user’s login name is used. For more information see the passwd command man page by typing the following passwd command:
man passwd
man 5 passwd
man 5 shadow

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

🐧 2 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
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
2 comments… add one
  • kris Jan 2, 2013 @ 17:25

    Thanks…very useful

  • ansar Aug 23, 2016 @ 6:45

    really thank you man

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