How to change a user’s password in Linux?

For change password of a user on Linux, first open the window Terminal. Depending on your access rights, you can proceed in two ways:

  • If you wish change your own password, type the command passwd and press Entrance ; follow the instructions displayed.
  • For change another user’s password, log in as user root or use sudo. Then enter the command passwd username, replacing username by the name of the user concerned.

It is important to note that only users with the necessary rights can change the passwords of other accounts, while each user is responsible for their own password.

Changing a user’s password in Linux is a simple, but essential, operation that every system administrator should master. This article will guide you through the different methods to change the password, whether for your own account or that of another user, using the terminal. The necessary commands will be presented clearly to enable you to perform these tasks without difficulty.

Change your own password

When you want to change your own password in Linux, you need to open the terminal and follow the following simple procedure. First, type the command passwd and press Entrance. This will ask you to enter your current password to confirm your identity.

Once you have entered your current password, you will be prompted to enter a new password. It is recommended to choose a complex password to increase the security of your account. Complete this operation by confirming the new password. This process can be completed quickly and without additional processing, as long as you are logged in to your account.

Change another user’s password

Change another user's password

If you need to change another user’s password, you must be logged in as root or use sudo. Before you begin, open the terminal. Type the following command: sudo passwd username, replacing username by the name of the targeted user.

After running this command, you will be prompted to enter a new password for this user. As before, make sure the password is strong enough. Once the password is formulated and confirmed, it will be updated immediately.

Force a password change

In some cases, it may be necessary to force a password change for a user. This can be useful in situations where security needs to be increased. To do this, use the command chage. For example, the command sudo chage -d 0 username will force a password change the next time the user logs in.

After this command, the user will have to set a new password at their next login, thus ensuring that security is maintained. This method is often used for sensitive or privileged access accounts.

Security Considerations

Security Considerations

Password management is crucial for account security on Linux. It is advisable to follow some best practices when creating or changing passwords. For example, make sure your passwords contain a combination of letters, numbers and symbols, and avoid using easily accessible personal information.

It is also a good idea to regularly check user accounts and passwords to ensure they have not been compromised. To learn more about managing users and permissions, you can consult the resources available at: Manage users and permissions.

Remember that it is a good practice to change your passwords regularly and monitor any suspicious activity on your system. For more surprising Linux tips, check out this article: 5 Things You Probably Didn’t Know About Linux.

If you are planning to install Linux alongside Windows, you will find valuable information about the process in this article: Install Ubuntu in dual boot with Windows.