Did You Know? netcat is a unix utility which reads and writes data across network connections, using TCP or UDP protocol. It's designed to be a reliable back-end tool that can be used directly or easily driven by other programs and scripts. At the same time, it's a feature-rich network debugging and exploration tool, since it can create almost any kind of connection you would need and has several interesting built-in capabilities. Netcat, or "nc" as the actual program is named, should have been supplied long ago as another one of those cryptic but standard Unix tools.
-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
Now we can try login with user linuxconfig and see if that works:
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/'
To make account expire we can use --expiredate option. This will expire user account on 1 January 2010.