Pages

Friday, November 30, 2012

How To Lock/Unlock User Accounts From The Terminal Under Ubuntu/Linux Mint


In a previous article, we have seen how to add/remove user accounts from the terminal under Ubuntu/Linux Mint. Today, we will see how to lock or unlock a specific user account from the terminal using two methods.

Method 1 (Recommended)

To lock a user account, open the terminal and run this command:


sudo usermod --expiredate 1 username

Replace username with the user account name you want to disable. The user account in question will no longer be able to login using its password either locally or remotely. To unlock it, use this command:

sudo usermod --expiredate -1 username

The user account name will now be able to log in to its session.

Method 2

Alternatively, you can use this command to lock a user account:

sudo passwd -l username

Replace username with the user account name you want to lock. If the command is successful, you will get this output:

passwd: password expiry information changed.

However, the user may have access to its account remotely (via SSH). So, the first method is highly recommended. To unlock the same account, you can execute this command:

sudo passwd -u username

Note: You can use this tip under Ubuntu 12.10/12.04 and Linux Mint 14 or older.

No comments:

Post a Comment