feed-image  ISSN 1836-5930

linux

Linux eBooks FREE Download

A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide


Poll

Do you care about your privacy when using a FACEBOOK?
 


Partner Linux Sites: TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux
usermod
Article Index
1. Name
2. Synopsis
3. Frequently used options
4. Examples

1. Name

usermod [man page] - modify a user account

2. Synopsis

usermod [options] LOGIN 

3. 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.

4. 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 

usermod - lock user account
Now we can try login with user linuxconfig and see if that works:

usermod - login test
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/' 
usermod - unlock user account
To make account expire we can use --expiredate option. This will expire user account on 1 January 2010.
# usermod --expiredate 2010-01-01 linuxconfig 
usermod - set expire date