900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > linux中更改用户密码_如何在Linux中更改用户密码

linux中更改用户密码_如何在Linux中更改用户密码

时间:2019-02-21 02:01:45

相关推荐

linux中更改用户密码_如何在Linux中更改用户密码

linux中更改用户密码

In this tutorial, we will focus on how you can change a user’s password in Linux. We will delve deeper and see how to force a user to change their password the next time they try logging in. These commands are standard and will work for any Linux distribution.

在本教程中,我们将重点介绍如何在Linux中更改用户密码。 我们将进行更深入的研究,并了解如何在用户下次尝试登录时强制其更改密码。这些命令是标准命令,适用于任何Linux发行版。

Let’s jump right in.

让我们跳进去。

1.更改您的用户密码 (1. Changing your user password)

As a regular user in a Linux system, you can only change your password. The root user is the only user that can change the passwords of other users.

作为Linux系统的普通用户,您只能更改密码。 root用户是唯一可以更改其他用户密码的用户。

The command used for changing users’ password is thepasswdcommand. It is usually followed by the username of the user whose password you want to change i.e.

用于更改用户密码的命令是passwd命令。 通常,其后是要更改其密码的用户的用户名,即

# passwd your_username

For example, if you want to change the password of a userjamie, execute

例如,如果要更改用户jamie的密码,请执行

# passwd jamie

You will be prompted to type your current password and later provide the NEW password and confirm it.

系统将提示您输入当前密码,然后提供新密码并进行确认。

Sample Output

样本输出

When providing a new password , ensure that you use aSTRONGandUNIQUEpassword. A strong password should have the following.

提供新密码时,请确保使用STRONG密码和UNIQUE密码。 强密码应具有以下内容。

It should have a combination of Uppercase, Lowercase, Numeric and Special characters它应包含大写,小写,数字和特殊字符的组合 It should have more than 8 Characters它应该超过8个字符 It should not contain your biometric details such as name, date of birth, place of residence to mention a few.它不应包含您的生物特征详细信息,例如姓名,出生日期,居住地点等。

Passwords are stored in an ecrrypted format in the/etc/gshadowfile.

密码以加密格式存储在/etc/gshadow文件中。

2.更改其他用户的Linux密码 (2. Changing Linux password for another user)

As discussed before, only the root user can change other users’ password. So, you need to log in as the root user to do this.

如前所述,只有root用户可以更改其他用户的密码。 因此,您需要以root用户身份登录才能执行此操作。

Once logged in run the command as earlier shown to change a users password

登录后,运行前面显示的命令以更改用户密码

# passwd username

Once again, you will be prompted for the new password and asked to confirm it.

再次,将提示您输入新密码并要求您确认。

Sample Output

样本输出

3.强制用户在下次登录时更改密码 (3. Forcing a user to change password at the Next Login)

Usually, passwords are not set to expire. But, you can force a user to change their password the next time they log in to the Linux system.

通常,密码未设置为过期。 但是,您可以强制用户在下次登录Linux系统时更改其密码。

To do this , use thepasswdcommand with--expireoption followed by the username of the user:

为此,请使用带有--expire选项的passwd命令以及用户名:

$ passwd --expire jamie

The next time user logs in with their old password, they will be forced to change the password.

下次用户使用旧密码登录时,将被迫更改密码。

Sample Output

样本输出

That concludes this tutorial on How to change a user’s password in Linux. Your contribution and feedback are most welcome.

到此为止,本教程有关如何在Linux中更改用户密码。 非常欢迎您的贡献和反馈。

翻译自: /28658/change-user-password-linux

linux中更改用户密码

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。