• Home
  • Disclaimer
  • Contact
  • Archives
  • About
  • Subscribe
  • Support
  • Advertise

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
    • Troubleshooting
  • OS
    • HPUX
    • Linux
  • Miscellaneous
    • Software & Tools
    • Cloud Services
    • System services
    • Virtualization
  • Certification Preparations
    • AWS Certified Solutions Architect – Associate
    • AWS Certified Solutions Architect – Professional
    • AWS Certified SysOps Administrator – Associate
    • AWS Certified Cloud Practitioner
    • Certified Kubernetes Administrator
    • Hashicorp Certified Terraform Associate
    • Oracle Cloud Infrastructure Foundations 2020 – Associate
  • Tips & Tricks
  • Linux commands
You are here: Home / Linux

Account lock unlock status in Linux

Published: October 2, 2016 | Modified: June 20, 2020



Learn how to check account lock unlock status in Linux. Also, check how to lock or unlock accounts manually with commands.

Requirement :

To check the current password status of the account in Linux.

Solution :

1. To check if the account is locked or not

Below are two examples of command outputs when the account is locked and when the account is not locked.

If the account is locked out then passwd -S clearly shows Password locked or else it will show Password set status.

# passwd -S user1
user1 LK 2016-10-01 0 90 7 -1 (Password locked.)
# passwd -S user1
user1 PS 2016-10-01 0 90 7 -1 (Password set, MD5 crypt.)

Also by observing the encrypted password field in /etc/shadow file, account status can be determined. If encrypted password entry is preceded by !! then the account is locked.

# cat /etc/shadow |grep -i user1
user1:$1$ZFXgKhSG$lroasdrS0QM4iji.4h1:17075:0:90:7:::  
# cat /etc/shadow |grep -i user1
user1!!$1$ZFXgKhSG$lroasdrS0QM4iji.4h1:17075:0:90:7:::  
2. Lock account manually.

Sometimes it is advisable to lock accounts manually if you are suspecting some malicious activity from account. In such cases, the account can be locked instantly using the below command. Please be advised that current live sessions of that account are not affected when you are locking it out. You have to clear off /terminate currently active sessions manually to kick the user out of the system. The user won’t be able to log in to the system after the lockout.

# passwd -l user1
Locking password for user user1.
passwd: Success
3. Unlock the account manually.

To unlock any locked account on the system below command can be used. Like above active sessions are not affected here as well.

# passwd -u user1
Unlocking password for user user1.
passwd: Success.
⇠ Previous article
Password file commands
Next article ⇢
Basics of LVM legends

Related stuff:

  • How to start, stop and reload postfix
  • Why ps output shows UID instead of username
  • LVM commands tutorial : Part 1 : Physical Volume (pvcreate, pvdisplay)
  • RHEL6 boot process
  • Ulimit value : All you need to know
  • NFS configuration in Linux and HPUX
  • All you need to know about hostname in Linux
  • Format date and time for Linux shell script or variable
  • 5 different examples to send email through Linux terminal
  • Content Lifecycle Management in SUSE Manager
  • How to configure NTP client in Linux
  • sar command (Part III) : Disk, Network reporting

Filed Under: Linux Tagged With: how to check if account is locked in linux, how to lock account in linux, how to unlock account in linux, lock account in linux, lock account manually, Unlock account Linux

If you like my tutorials and if they helped you in any way, then

  • Consider buying me a cup of coffee via paypal!
  • Subscribe to our newsletter here!
  • Like KernelTalks Facebook page.
  • Follow us on Twitter.
  • Add our RSS feed to your feed reader.

Comments

  1. Kiplangat says

    February 4, 2018 at 2:25 am

    Yiu can check the status using chage -l
    Lock account: chage -L
    Unlock: chage -U

    Reply

Share Your Comments & Feedback: Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get fresh content from KernelTalks

  • Email
  • Facebook
  • RSS
  • Twitter

Get Linux & Unix stuff right into your mailbox. Subscribe now!

* indicates required

This work is licensed under a CC-BY-NC license · Privacy Policy
© Copyright 2016-2023 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.