如何在Linux中设置或更改用户密码?

Linux passwords are used to authenticate users. Linux passwords was hold in /etc/passwd file with other user related information like default shell, home directory path etc. Now in modern Linux distributions holds passwords in /etc/shadow file which have restricted access. This file holds user passwords as hash values with salt. Hashing and salting makes passwords more secure.

Linux密码用于验证用户。 Linux密码与其他与用户相关的信息(如默认外壳程序,主目录路径等)一起保存在/etc/passwd文件中。现在,在现代Linux发行版中,密码在/etc/shadow文件中保存,但访问受到限制。 此文件将用户密码保存为带有salt的哈希值。 哈希和加盐使密码更安全。

更改当前用户密码 (Change Current User Password)

To change a user password we need password change privilege. For currently logged user we can change passwords just like below.

要更改用户密码,我们需要密码更改权限。 对于当前登录的用户,我们可以如下更改密码。

$ passwd
Change Current User Password
Change Current User Password
更改当前用户密码
  • passwd command will start change process for current user which is root.

    passwd命令将启动当前用户(root)的更改过程。

  • New password: is asking new password and will not be printed to the screen for security reasons.

    新密码:正在询问新密码,出于安全原因,不会将其打印到屏幕上。

  • BAD PASSWORD is prompted because I have entered easy to crack password. For your productions systems please chose strong passwords.

    提示输入错误密码,因为我输入了容易破解的密码。 对于您的生产系统,请选择强密码。

  • Retype new password: is asking to enter same password for second time to avoid mistakes.

    重新输入新密码:要求第二次输入相同的密码,以免出错。

  • passwd: shows that password update process is completed successfully.

    passwd:表明密码更新过程已成功完成。

更改其他用户密码。 (Change Different User Password.)

To change other user password we need to be root user. We will provide the username to the passwd command in order to change user password. In this example we will change the password of user test

要更改其他用户密码,我们需要成为root用户。 我们将用户名提供给passwd命令以更改用户密码。 在此示例中,我们将更改用户test的密码

$ passwd test 
Changing password for user test. 
New password:  
BAD PASSWORD: The password is shorter than 8 characters 
Retype new password:  
passwd: all authentication tokens updated successfully.

  • This is very similar to previous password change operation.

    这与以前的密码更改操作非常相似。

修改组密码 (Change Group Password)

Linux operating system provides group for flexible privilege management. All users may have one or more groups. These groups also have passwords too. We can also change these password. We will use gpasswd command in order to change group password. In this example we will change the group ismail password.

Linux操作系统提供了用于灵活特权管理的组。 所有用户都可以有一个或多个组。 这些组也有密码。 我们也可以更改这些密码。 我们将使用gpasswd命令来更改组密码。 在此示例中,我们将更改组ismail密码。

$ sudo gpasswd ismail
Change Group Password
Change Group Password
修改组密码
LEARN MORE  Linux Etc Login.defs Configuration with Examples
了解更多Linux Etc Login.defs配置示例

如何在Linux中设置或更改用户密码? 信息移植 (How To Set or Change User Password In Linux? Infografig)

How To Set or Change User Password In Linux? Infografig
How To Set or Change User Password In Linux? Infografig
如何在Linux中设置或更改用户密码? 信息移植

翻译自: https://www.poftut.com/set-change-user-password-linux/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值