Get Geeky!

Life in a geek's world…

Main menu

Skip to primary content
Skip to secondary content
  • Home
  • About

Post navigation

← Previous Next →

Lock user account under Linux

Posted on 2009-03-12 by saz

Ever wanted to lock an user account under Linux, but don’t know how?

Well, today, I was in this situation, but don’t know, how to do it. Now I know :)

Lock user account:

1
root@host:~# passwd -l username

This will change the password to a value, which won’t match a possible encrypted value.

Unlock user account:

1
root@host:~# passwd -u username

This will change the password back to it’s original value.

If you want to know the status of an account (or all of them), you can use

1
2
# List all accounts
root@host:~# passwd -S -a|awk '($2 == "L")'
1
2
# List one account
root@host:~# passwd -S username

An “L” at the second position shows that an account is locked, a “P” marks a valid password, “NP” stands for “No Password”.
Have a look at man passwd to find out more. But be sure to read the english man page, as the german version is lacking some information (it took me quite some time to find out what ‘-a’ stands for).

This entry was posted in Linux and tagged account, Linux, lock user by saz. Bookmark the permalink.
Proudly powered by WordPress