Pages

Linux locking an account


passwd command is used to change user or group accounts password. A normal user may only change the password for his/her own account, the super user (root) may change the password for any account. You can use passwd command for locking or unlocking an account.

Linux locking an account
Syntax:
passwd -l {username}

Lock the account. This option disables an account by changing the password to a value which matches no possible encrypted value.

Example:
Lock user account named vivek. Login as a root user and type following command:

# passwd -l vivek
Linux unlocking an account
Syntax:
passwd -u {username}

Unlock the account. This option re-enables an account by changing the password back to its previous value i.e. to value before using -l option.

Example:
Unlock user account named vivek. Login as a root user and type following command:

# passwd -u vivek
See also:
  • Search for all account without password and lock them (includes sample script for FreeBSD/Linux/Sun Solaris)