How to Change the Password in Linux

How to Change the Password in Linux

It is very easy to change the password in Linux. Password protects your system from unauthorized access and changing it at regular intervals can further strengthen the security of your system. This article elaborates on ways to change the password and different commands to do so.
Techspirited Staff
Linux is an operating system just like, Mac, Windows XP, Windows Vista, Windows 7, etc. However, it is much safer and has better security as compared to other systems to protect itself from various threats. One can limit the access to a system by setting a password. The command to change the password in Linux is passwd. The rules for setting a password in Linux are same as in other operating systems.

If you are the root user, then you have the authority to alter your password along with that of other users in a system. However, a common user can just change his own password. The syntax to change the password of a user in Linux is as follows.

Passwd Username

On typing this command, you will be prompted to enter the old password. Once you enter it and hit the enter key, you will be prompted to enter and re-enter the new password that you wish to have. Once you are done with the procedure, you will be informed that the changes have been made successfully. However, one thing you need to keep in mind is that, when you type in your password in Linux, it does not display any asterisk sign or dot, as in the case of other operating systems. Now, let us take a look at the passwd command in detail.

Passwd Command

This command allows you to change various other features. They are as follows:
  • It allows you to change the full name and username of a particular user. If you type passwd -s you will get the complete information of a user whose username is followed by the command. Besides the name, password, and the date on which the user id was created, you also get the minimum and maximum number of days for which the password would be valid.
  • passwd -g is used for changing the password of a group.
  • If you set the warn field using the command passwd -w, you can set the number of days before which the user will be warned to change the password.
  • The passwd -d command allows you to alter the password for a particular user.
  • passwd -n allows you to assign the number of days between changing your password.
  • passwd -h allows you to alter the home directory for a particular user.
  • passwd -l forces the user to alter the password at the next login, by expiring the earlier for that particular name.
Besides the commands mentioned above, you can try other options like passwd -a, which shows the password entry for all the users in a system.

The above mentioned features make this operating system one of the most secure to use. It is also to be noted that this system was originally an open source system.