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
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