Published on

Changing Passwords in Linux

Authors
  • avatar
    Name
    hwahyeon
    Twitter

How to Change Passwords in Linux

1. Change the current user's password

$ passwd
Changing password for user alice.
Current password:
New password:
Retype new password:
  • Here, alice represents the username of the currently logged-in user.

2. Change another user's password (example: john, requires admin privileges)

$ sudo passwd john
[sudo] password for alice:    # enter alice's password to confirm sudo privileges
Enter new UNIX password:      # set a new password for john
Retype new UNIX password:
  • The first prompt is for the current user (alice) to verify sudo access.
  • After that, you can set the new password for the target user (john).

3. Change the root account password

$ sudo passwd
[sudo] password for alice:    # verify sudo privileges
Enter new UNIX password:      # set a new password for root
Retype new UNIX password:
  • The process is the same: verify with alice’s password, then set the new root password.