Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to change the account password in Linux

Shulou Source: shulou.com Published: 2022-06-01 20:34:26 10月02日 Update

What this article shares to you is about how to change the account password in Linux. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

Change the password of a personal account

Ordinary users who want to change their personal account password simply run the passwd command without any other commands:

$passwd

Sample output:

Changing password for nick (current) UNIX password:Enter new UNIX password:Retype new UNIX password:passwd: password updated successfully

We will be prompted to enter the current password first and, if the password is correct, to re-enter and confirm the new password. The next time you log in to the Linux system, you can log in with the new password.

Note: when entering a password, the password will not be displayed on the screen.

Change another user's password

As an ordinary user, you can only change your own password. However, root users and users with sudo privileges can change the passwords of other users.

We need to log in as root, type the following command to change the password of user nick:

$passwd nick

Or use the sudo command

$sudo passwd nick

Output: you will be prompted to enter and confirm the new password

Enter new UNIX password:Retype new UNIX password:passwd: password updated successfully

Force the user to change the password the next time they log in

By default, the password is set to never expire. If you want to force the user to change their password the next time you log in, you need to use the command passwd with-- expireoption, followed by the user's user name, for example:

$sudo passwd-expire nick

This immediately causes the password of the user account to expire.

The next time a user tries to log in with the old password, a message will be displayed forcing them to change the password:

$ssh nick@192.168.121.209

Output:

WARNING: Your password has expired.You must change your password now and login changing password for nick. (current) UNIX password:Enter new UNIX password:Retype new UNIX password:passwd: password updated successfullyConnection to 192.168.121.209 closed. What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

The above is how to change the account password in Linux. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Password user system command input account secondary login new secret mandatory login output normal operating system personal account more knowledge article prompt run Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MariaDB macOS Microsoft OPPO Reno