How to change password in Linux

Changing your password is one of the most common basic commands in Linux. This post covers how to change password in Linux when a user wants to change their current password. Keep in mind that this is a different scenario from a user who has forgotten their password and needs to reset password, which is covered in another post.
The command to change a password in Linux is the same for all types of users, regardless of their privileges, whether it is a sudo user or a normal user.
To change your password in Linux, first log in to your system, either by connecting through SSH or by logging in directly. If you are connecting through SSH, do not close the current session until you have first logged in with the new credentials.
Once you are logged in, type passwd username. If you are root, passwd alone is enough.

While you type the new password, you will not see asterisks (*) or any other characters. Don’t worry and keep typing: this is a security feature in Linux.
A normal user has permission to change their own password, but root can revoke this permission. In that case, you will get a “permission denied” error.