shell

Locking a user account

# passwd -l user

Locks user‘s account, that is, prevents user from logging in.

Note: This option is available in Linux and Solaris. In Mac OS X, -l option means something different:

# passwd -l location user

Here, -l changes the password in location. Valid values are:

  • file: a filename. Default is /etc/master.passwd
  • netinfo: a domain name or server/tag pair
  • nis: an NIS domain name
  • opendirectory: a directory node name

3 Comments

  • On 02.03.09 cservant said:

    Not always.

    Some variants of passwd may not have this flag, others may mean something else. Better to man passwd (command not file or database) to see what is available. Better yet, just edit the passwd file to lock out users.

  • On 02.07.09 rafacas said:

    You are right cservant. the -l option is only available for Solaris and Linux. I use to tag the post with the OS that allow the command and the option, but this time I forgot it. I am updating the post. Thanks :)

  • On 02.08.09 commandliners » Unlocking a user account said:

    […] user’s account. That is, lets user log in (a locked account is one prevented from logging in). Tagged: linux, passwd, […]

speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*Required Fields