How to Unlock a User Account in Linux

How to Unlock a User Account in Linux

Hey there! 👋 If you're a beginner in Linux and you've come across a situation where a user account is locked, don’t worry — unlocking it is simple! In this tutorial, I’ll guide you through the steps to check and unlock a user account using the terminal. This is especially useful if a user has been locked out after too many failed login attempts or was manually locked by an admin.

🔐 Step 1: Check If a User Account Is Locked

Let’s say the username is john. To check if the account is locked, we’ll use the passwd -S command:

sudo passwd -S john
john L 06/30/2025 0 99999 7 -1

The letter L in the second column means the account is Locked. If you see a P, it means the account is Active (Password set).

🔓 Step 2: Unlock the User Account

To unlock the user account, just run the following command:

sudo passwd -u john
passwd: password expiry information changed.

That’s it! The user john can now log in normally.

👀 Optional: Verify Unlock Status

You can recheck the status to make sure the account is now unlocked:

sudo passwd -S john
john P 06/30/2025 0 99999 7 -1

Notice the P now? That means the account is active again!

🚧 Bonus: What If It’s a Locked Shell?

Sometimes, accounts are locked by assigning /sbin/nologin or /bin/false as their login shell. To fix that, you can change the shell like this:

sudo usermod -s /bin/bash john

This ensures the user has access to a valid shell.

🎉 That’s a Wrap!

And that’s how you unlock a user account in Linux! Whether you’re managing your own machine or helping a colleague, you now know exactly what to do when a user gets locked out.

Want to keep learning? Explore more Linux tutorials and hands-on examples with us on programguru.org 🚀