Usermod


From Linuxconfig.org

Jump to: navigation, search

.. back to the list of Linux Commands

Name

usermod - modify a user account

Synopsis - man page

usermod [options] LOGIN

Frequently used options

-e, --expiredate EXPIRE_DATE
      The date on which the user account will be disabled. The date is
      specified in the format YYYY-MM-DD.
-L, --lock
      Lock a user’s password. This puts a ’!’ in front of the encrypted
      password, effectively disabling the password. You can’t use this
      option with -p or -U.
-U, --unlock
      Unlock a user’s password. This removes the ’!’ in front of the
      encrypted password. You can’t use this option with -p or -L.

Examples

Lets see how we can lock account for user linuxconfig. This will add "!" into /etc/shadow for user linuxconfig. NOTE: this command requires superusers privileges.

# usermod -L linuxcofnig
Image:usermod01.gif

Now we can try login with user linuxconfig and see if that works:

Image:usermod02.gif

With a -U option we can unlock account:

# usermod -U linuxcofnig

Check if the "!" is removed from etc/shadow:

# grep linuxconfig etc/shadow | head -c 15 |  sed -e 's/$/\n/'
Image:usermod03.gif

To make account expire we can use --expiredate option. This will expire user account on 1 January 2010.

# usermod --expiredate 2010-01-01 linuxconfig
Image:usermod04.gif

.. back to the list of Linux Commands

Personal tools
Linux Commands