当执行该sudo adduser <username> --disabled-login
命令时,会创建一个被锁定的用户,因为已禁用登录。可以使用以下passwd -S <username>
命令进行确认,如下所示:
<username> L ...
要解锁,首先需要定义一个密码,因此可以使用passwd
或usermod
命令来实现这一目标,如下所示:
sudo passwd -u <username>
passwd: unlocking the password would result in a passwordless account.
You should set a password with usermod -p to unlock the password of this account.
sudo usermod -U <username>
usermod: unlocking the user's password would result in a passwordless account.
You should set a password with usermod -p to unlock this user's password.
因此指示两次使用该usermod -p
命令。现在根据man usermod
指示的选项-p
指示
-p, --password PASSWORD
The encrypted password, as returned by crypt(3).
Note: This option is not recommended because the password
(or encrypted password) will be visible by users listing
the processes.
The password will be written in the local /etc/passwd or
/etc/shadow file. This might differ from the password
database configured in your PAM configuration.
You should make sure the password respects the system's
password policy.
我担心的是笔记指示。它在某种程度上被弃用了吗?因此
问题
- 解锁的正确方法是什么已禁用登录用户?