Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of changing account password in Linux

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the method of changing the account password in Linux, which is very detailed and has a certain reference value. Interested friends must read it!

Both Linux and UNIX-like operating systems use the passwd command to change the user's password.

In Linux, if the encrypted user password and other password-related information are stored in the / etc/shadow file, the user password can be changed using the passwd command.

When changing your password, be sure to use a strong and unique password. Having a strong password is the most important thing to protect your account. Strong passwords usually contain at least 16 characters, using at least one uppercase letter, one lowercase letter, one number, and one special character.

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.

After the user sets the new password, the connection is closed.

The above is all the contents of the method of changing the account password in Linux. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report