上QQ阅读APP看书,第一时间看更新
Using usermod to lock a user account
Let's say that Katelyn has gone on maternity leave and will be gone for several weeks. We can lock her account with the following:
sudo usermod -L katelyn
When you look at Katelyn's entry in the /etc/shadow file, you'll now see an exclamation point in front of her password hash, as follows:
katelyn:!$6$uA5ecH1A$MZ6q5U.cyY2SRSJezV000AudP.ckXXndBNsXUdMI1vPO8aFmlLXcbGV25K5HSSaCv4RlDilwzlXq/hKvXRkpB/:17446:0:99999:7:::
This exclamation point prevents the system from being able to read her password, which effectively locks her out of the system.
To unlock her account, just do this:
sudo usermod -U katelyn
You'll see that the exclamation point has been removed so that she can now log in to her account.