usermod
The usermod command allows you to modify an existing user in the system. It works in
much the same way as useradd. Its usage is summarized here:
usage: usermod [-u uid [-o]] [-g group] [-G group,...]
[-d home [-m]] [-s shell] [-c comment] [-l new_name]
[-f inactive] [-e expire ] [-p passwd] [-L|-U] name
Every option you specify when using this command results in that particular parameter
being modified for the user. All but one of the parameters listed here are identical to the
parameters documented for the useradd command. The one exception is -l.
The -l option allows you to change the user’s login name. This and the -u option are
the only options that require special care. Before changing the user’s login or UID, you
must make sure the user is not logged into the system or running any processes. Chang-
ing this information if the user is logged in or running processes will cause unpredictable
results.
Modifying User Attributes with usermod
Now try using usermod to change the user and group IDs for a couple of accounts.
1. Use the usermod command to change the user ID (UID) of the bogususer to
600. Type [root@fedora-serverA ~]# usermod -u 600 bogususer
2. Use the id command to view your changes. Type
[root@fedora-serverA ~]# id bogususer
The output shows the new UID (600) for the user.
3. Use the usermod command to change the primary group ID (GID) of the bogus-
user account to that of the bogus group (GID = 101) and to also set an expiry date
of 12-12-2010 for the account. Type
[root@fedora-serverA ~]# usermod -g 497 -e 2010-12-12 bogususer
4. View your changes with the id command. Type
[root@fedora-serverA ~]# id bogususer
5. Use the chage command to view the new account expiration information for
the user. Type
[root@fedora-serverA ~]# chage -l bogususer
Last password change : Sep 23, 2009
Password expires : never
Password inactive : never
Account expires : Dec 12, 2010
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
6 to change user name for an account:- usermod -l newuser user
No comments:
Post a Comment