Change the Password in UNIX

last updated in Categories , , , ,

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

Conclusion

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

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive

2 comment

    Still, have a question? Get help on our forum!