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

Kernel Talks

Unix, Linux, & Cloud!

  • How-to guides
    • Howto
    • Disk management
    • Configurations
  • OS
    • HPUX
    • Linux
  • Commands & tools
    • Commands
    • Software & Tools
    • System services
  • Cloud computing
    • AWS CSA preparation guide!
    • Cloud Services
  • Tips & Tricks
  • Linux commands
You are here: Home / Linux

Account lock unlock status in Linux

Published: October 2, 2016 | Modified: June 20, 2020 | 8,329 views



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:

  • Process states in Linux
  • Basics of LVM legends
  • LVM commands tutorial : Part 1 : Physical Volume (pvcreate, pvdisplay)
  • LVM commands tutorial : Part 1 : Physical Volume (pvchange, pvmove)
  • 5 different examples to send email through Linux terminal
  • Content Lifecycle Management in SUSE Manager
  • Linux mascot penguin: TUX
  • Move disks/LUN from one server to another without losing data
  • How to scan new lun / disk in Linux & HPUX
  • What’s new in RHEL 8
  • SUSE Manager Server 4 installation with screenshots
  • lolcat: a tool to rainbow color Linux terminal

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

Popular posts

  • How to start, stop & restart MariaDB server in Linux
  • How to list YUM repositories in RHEL / CentOS
  • How to reset iptables to the default settings
  • 4 ways to check the size of physical memory (RAM) in Linux
  • How to upgrade package using YUM in RHEL
  • MobaXterm X11 proxy: Authorisation not recognised
  • How to disable iptables firewall temporarily
  • How to enable repository using subscription-manager in RHEL
  • Configuring Visual Studio Code for Terraform to work with AWS
  • How to remount filesystem in the read-write mode under Linux

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-2020 KernelTalks · All Rights Reserved.
The content is copyrighted to Shrikant Lavhate & can not be reproduced either online or offline without prior permission.