Modifying Accounts

Modifying Accounts

Occasionally, a user needs more done to an account than just a resetting of the password. You may need to change the groups that user is in, or the drive that a home directory resides on. The following sections explain how to modify user accounts using one of two methods: usermod or the Red Hat User Manager.

Modifying user accounts with usermod

The usermod command is similar to the useradd command and even shares some of the same options. However, instead of adding new accounts, it enables you to change various details of existing accounts. When invoking the usermod command, you must provide account details to change followed by the login name of the account. Table 11-3 lists the available options for the usermod command.

Table 11-3: usermod Options for Changing Existing Accounts



-c comment

Change the description field of the account. You can also use the chfn command for this. Replace comment with a name or other description of the user account, placing multiple words in quotes.

-d home_dir

Change the home directory of the account to the specified new location. If the -m option is included, copy the contents of the home directory as well. Replace home_dir with the full path to the new directory.

-e expire_date

Assign a new expiration date for the account, replacing expire_date with a date in MM/DD/YYYY format.

-f inactivity

Set the number of days after a password expires until the account is permanently disabled. Setting inactivity to 0 disables the account immediately after the password has expired. Setting it to -1 disables the option, which is the default behavior.

-g group

Change the primary group (as listed in the /etc/group file) that the user is in. Replace group with the name of the new group.

-G grouplist

Set the list of groups that user belongs to. Replace grouplist with a list of groups.

-l login_name

Change the login name of the account to the name supplied after the -l option. Replace login_name with the new name. This automatically changes the name of the home directory; use the -d and -m options for that.


This option is used only in conjunction with the -d option. It causes the contents of the user's home directory to be copied to the new directory.


This option is used only in conjunction with the -u option. It removes the restriction that user IDs must be unique.

-s shell

Specify a new command shell to use with this account. Replace shell with the full path to the new shell.

-u user_id

Change the user ID number for the account. Replace user_id with the new user ID number. Unless the -o option is used, the ID number must not be in use by another account.

Assume that a new employee named Jenny Barnes will be taking over Mary's job. We want to convert the mary account to a new name (-l jenny), new comment (-c "Jenny Barnes"), and home directory (-d /home/jenny). We could do that with the following command:

# usermod -l jenny -c "Jenny Barnes" -m -d /home/jenny mary

Furthermore, if after converting the account we learn that Jenny prefers the tcsh shell, we could make that change with the -s option (-s /bin/tcsh):

# usermod -s /bin/tcsh jenny

Instead, we could use the chsh command to change the shell. The following is an example:

# chsh -s /bin/tcsh jenny

The chsh command is handy because it enables a user to change his or her own shell setting. Simply leave the user name parameter off when invoking the command, and chsh assumes the currently logged-in user as the account to change.

Modifying user accounts with Red Hat User Manager

To use the desktop to change an existing account, you can use the Red Hat User Manager. Here's how to add a new user from the Red Hat User Manager window:

  1. From the Red Hat menu, click on System Settings? Users and Groups (or type redhat-config-users from a Terminal window as root user). The main Red Hat User Manager window appears.

  2. Click on the user name of the account you want to modify, then select the Properties button. A User Properties window appears, as shown in Figure 11-3.

    Click To expand
    Figure 11-3: Choose Properties to modify an existing user account.

  3. There are four tabs of information you can modify for the user you selected:

    • User Data ( This tab contains the user information you created when you first added the user account.

    • Account Info ( Click on "Enable account expiration" and type a date if you want the account to become inaccessible after a particular date. Click on "User account is locked" if you want to prevent access to the account but not delete it. (The latter is a good technique when an employee is leaving the company or if you want to lock out a customer whose account is temporarily disabled. The information isn't removed, it just isn't accessible.)

    • Password Info ( Click on "Enable password expiration" if you want to control expiration of the user's password. By default, passwords don't expire. Here are your options: "Days before change allowed" (forces the user to keep the password for at least a set number of days before it can be changed); "Days before change required" (allows the user to keep the same password for at least the set number of days); "Days warning before change" (sets how many days before the password expiration day that the user is warned to change the password); "Days before account inactive" (sets the number of days after which the account is deactivated).

    • Groups ( Select from the list of available groups to add the user to one or more of those groups.

  4. Click Apply to apply the changes to the user account.

Part IV: Red Hat Linux Network and Server Setup