When managing a Linux server or working in the terminal, it is crucial to keep your account secure. One of the most basic security practices is regularly changing your user password. You do not need a graphical user interface to do this; Linux provides a simple, built-in command specifically for managing passwords.
How to Change Your Own Password
If you are logged into your user account and simply want to update your own password, you use the passwd command.
- Open your terminal application (or connect to your server via SSH).
- Type
passwdand press Enter. - The system will first prompt you for your (current) UNIX password. Type it in and press Enter. (Note: As a security feature, nothing will appear on the screen while you type, not even asterisks).
- Next, it will ask for your New password. Type it and press Enter.
- Finally, it will ask you to Retype new password to confirm.
If they match, you will see a message saying “passwd: password updated successfully.”
How to Change Another User’s Password (Root)
If you are a system administrator and need to reset a password for a different user who has forgotten theirs, you must use sudo privileges.
sudo passwd username
Replace username with the actual login name of the user you want to modify. For example, sudo passwd john.
Because you are acting as the root user (via sudo), the system will not ask you for John’s current password. It will immediately prompt you to enter the new password twice. This is incredibly useful for resetting lost credentials on a system.