Administering User AccountsObjective: Explain and perform Solaris 10 OS user administration, and manage user accounts and initialization files. Access to a system is allowed only through user login accounts that are set up by the system administrator. A user account includes information that a user needs to log in and use a systema user login name, a password, the user's home directory, and login initialization files. Each of these items is described later in this chapter. The following methods and tools are available in Solaris for adding new user accounts to a system:
As with many Unix commands, the command-line method of adding user accounts can be difficult for inexperienced administrators. For this reason, Sun has added user account administration to the Solaris Management Console (SMC). Managing User and Group Accounts with the SMCThe SMC is a GUI that is designed to ease several routine system administration tasks. When you use the SMC, you are presented with a menu-like interface that is much easier to use than the ASCII interface supplied at the command prompt. This chapter describes how to use the SMC and the command line to administer user accounts on a system. Adding User Accounts with the SMCTo perform administrative tasks such as adding user accounts, SMC will prompt you for the root password or an authorized RBAC account before allowing permission to add, create, and modify user accounts. Chapter 11, "Controlling Access and Configuring System Messaging," provides more information on RBAC. Note Editing User Accounts Files When you're adding or modifying user accounts, the SMC edits the files /etc/passwd, /etc/shadow, and /etc/group. These files are described later in this chapter. As root, you could edit these files directly, but that is not recommended. Errors in any of these files could cause adverse effects on the system. The first step in setting up a new user account is to have the user provide the information you need in order to administer the account. You also need to set up proper permissions so that the user can share information with other members of his or her department. You need to know the user's full name, department, and any groups with which the user will be working. It's a good idea for the system administrator to sit down with the user and compile an information sheet (like the one shown in Table 4.1) so that you have all the information you need when you set up the account.
To use the SMC to add a new user login account, you should follow the procedure described in Step by Step 4.1. Exam Alert Using the SMC to Add a New User For the exam, you will not be asked to use the SMC to add a new user account, but you do need to know what tool within the SMC is used to add a user account. You also need to know what information the SMC asks for.
When you use the Add User Wizard to create an account, the following defaults are assigned to the account:
To modify these settings, refer to the section "Modifying User Accounts with the SMC," later in this chapter. Refer to the man pages for a description of this command. Deleting User Accounts with the SMCWhen a user account is no longer needed on a system, you need to delete it. Step by Step 4.2 describes how to perform this task.
Caution When selecting to remove the home directory, make sure that you are certain of the directory that will be removed. If you need data from this directory, do not remove it. Sometimes a user's home directory might point to an important directory such as "/" root. In this case, removing the home directory would remove important system files. Modifying User Accounts with the SMCIf a login needs to be modifiedto change a password or disable an account, for exampleyou can use the SMC to modify the user account settings, as described in Step by Step 4.3.
Adding Groups with the SMCAs a system administrator, you might need to add a group that does not already exist on the system. Perhaps a new group of users called engrg (from the Engineering Department) needs to be added. Step by Step 4.4 shows how to add this group to the system by using the SMC.
The /usr/sadm/bin/smgroup add command is the command-line equivalent of the SMC tool for adding a new group. For example, to add a group named development with a GID of 300, you enter this: /usr/sadm/bin/smgroup add -g 300 -n development The system responds with this: Authenticating as user: root Type /? for help, pressing <enter> accepts the default denoted by [ ] Please enter a string value for: password :: <Enter the Root Password> Loading Tool: com.sun.admin.usermgr.cli.group.UserMgrGroupCli from ultra5 Refer to the man pages for a complete description of the smgroup command. Managing User and Group Accounts from the Command LineYou can manage user accounts from the command line as well as through the SMC. Although using the command line is more complex than using the SMC GUI interface, the command line allows more options and provides a little more flexibility. Solaris supplies the user administration commands described in Table 4.3 for setting up and managing user accounts.
Note SMC Versus Conventional Administration Commands The SMC has its own command-line equivalents, such as smuser and smgroup. The difference between the SMC commands and the commands outlined in Table 4.3 is that the SMC can also update the name service. The commands in Table 4.3 only update the local files. Adding User Accounts from the Command LineYou can add new user accounts on the local system by using the useradd command. This command adds an entry for the new user into the /etc/passwd and /etc/shadow files, which are described later in this chapter, in the section "Where User Account Information Is Stored." Just like the SMC, the -m option to the useradd command copies all the user initialization files found in the /etc/skel directory into the new user's home directory. User initialization files are covered in the section "Setting Up Shell Initialization Files," later in this chapter. The syntax for the useradd command is as follows: useradd [-c comment] [-d dir] [-e expire] [-f inactive] [-g group] \
[ -G group [ , group...]] [ -m [-k skel_dir]] [-u uid [-o]] \
[-s shell] [-A authorization [,authorization...]]
[-P profile [,profile...]] \
[-R role [,role...]] [-p projname] [-K key=value] <loginname> Table 4.4 describes these options.
Many additional options are available, although most of them are not used as often as the ones in Table 4.4. Additional options to the useradd command apply specifically to RBAC accounts and are described in Chapter 11. You can also refer to the man pages to find a listing of all the options to the useradd command. The following example creates a new login account for Bill Calkins: useradd -u 3000 -g other -d /export/home/bcalkins -m -s /bin/sh \ -c "Bill Calkins, ext. 2345" bcalkins The login name is bcalkins, the UID is 3000, and the group is other. In this example, you instruct the system to create a home directory named /export/home/bcalkins. The default shell is /bin/sh, and the initialization files are to be copied from the /etc/skel directory. Note Assigning a UID If the -u option is not used to specify a UID, the UID defaults to the next available number above the highest number currently assigned. For example, if UIDs 100, 110, and 200 are already assigned to login names, the next UID that is automatically assigned is 201. The /usr/sadm/bin/smuser add command is the command-line equivalent of the SMC tool for adding a new user. The advantage of using smuser over the useradd command is that smuser interacts with naming services, can use autohome functionality, and is well suited for remote management. The smuser command has several subcommands and options. The syntax to add a user using smuser is smuser add [ auth args ] - [subcommand args] A few of the more common arguments that can be used with the add subcommand are described in Table 4.5.
The following example adds a new user named "bcalkins" and a comment field of "Bill Calkins ext. 100": # /usr/sadm/bin/smuser add -n bcalkins -c "Bill Calkins Ext 100"
Authenticating as user: root
Type /? for help, pressing <enter> accepts the default denoted by [ ]
Please enter a string value for: password :: <ENTER ROOT PASSWORD>
Loading Tool: com.sun.admin.usermgr.cli.user.UserMgrCli from smokey
Login to smokey as user root was successful.
Download of com.sun.admin.usermgr.cli.user.UserMgrCli from smokey
was successful. After you press Enter, the system asks for the root password to authenticate Bill Calkins before adding the new login account. The next step would be to set a password for the account using the passwd command as follows: # passwd bcalkins passwd: Changing password for bcalkins New Password: <ENTER PASSWORD> Re-enter new Password: <RE_ENTER PASSWD> passwd: password successfully changed for bcalkins Options that can be used with the passwd command are described in Table 4.6.
To force a user to change his or her password at the next login, type # passwd -f bcalkins passwd: password information changed for bcalkins # To change a user's home directory, type # passwd -h bcalkins The system responds with Default values are printed inside of '[]'. To accept the default, type <return>. To have a blank entry, type the word 'none'. Enter the new home directory when prompted: Home Directory [/home/wcalkins]: /home/bcalkins passwd: password information changed for bcalkins Modifying User Accounts from the Command LineYou use the usermod command to modify existing user accounts from the command line. You can use usermod to modify most of the options that were used when the account was originally created. The following is the syntax for the usermod command: usermod [ -u uid [-o]] [-g group] [ -G group [ , group...]]
[ -d dir [-m]] [-s shell] [-c comment] [-l new_name] [-f inactive]
[-e expire] [-A authorization2 [, authorization]] [-P profile
[, profile]] [-R role [, role]] [-K key=value] <loginname> The options used with the usermod command are the same as those described for the useradd command, except for those listed in Table 4.7.
Additional options to the usermod command apply specifically to RBAC accounts and are described in Chapter 11. The following example changes the login name for user bcalkins to wcalkins: usermod -d /export/home/wcalkins -m -s /bin/ksh -l wcalkins bcalkins This example also changes the home directory to /export/home/wcalkins and default shell to /bin/ksh. Note Modifying the Home Directory When you're changing the home directory, unless the -d and -m options are used, existing files still must be manually moved from the old home directory to the new home directory. In all cases, symbolic links, application-specific configuration files, and various other references to the old home directory must be manually updated. To set a user's account expiration date, you enter this: usermod -e 10/15/2006 wcalkins The account is now set to expire October 15, 2006. Notice the entry made to the /etc/shadow file: wcalkins:1luzXWgmH3LeA:13005:::::: The syntax of the /etc/shadow file is described later in this chapter, in the section "Where User Account Information Is Stored." The /usr/sadm/bin/smuser modify command is the command-line equivalent of the SMC tool for modifying an existing user account. Deleting User Accounts from the Command LineYou use the userdel command to delete a user's login account from the system. You can specify options to save or remove the user's home directory. The syntax for the userdel command is as follows: userdel [-r] <login-name> -r removes the user's home directory from the local file system. If this option is not specified, only the login is removed; the home directory remains intact. Caution Make sure you know where the user's home directory is located before removing it. Some users have / as their home directory, and removing their home directory would remove important system files. The following example removes the login account for bcalkins but does not remove the home directory: userdel bcalkins The /usr/sadm/bin/smuser delete command is the command-line equivalent of the SMC tool for deleting an existing user account. Adding Group Accounts from the Command LineYou use the groupadd command to add new group accounts on the local system. This command adds an entry to the /etc/group file. The syntax for the groupadd command is as follows: groupadd [-g <gid>] -o <group-name> Table 4.8 describes the groupadd command options.
The following example adds to the system a new group named acct with a GID of 1000: groupadd -g 1000 acct Note Assigning a GID If the -g option is not used to specify a GID, the GID defaults to the next available number above the highest number currently assigned. For example, if group IDs 100, 110, and 200 are already assigned to group names, the next GID that is automatically assigned is 201. The /usr/sadm/bin/smgroup add command is the command-line equivalent of the SMC tool for creating a new group. Modifying Group Accounts from the Command LineYou use the groupmod command to modify the definitions of a specified group. The syntax for the groupmod command is as follows: groupmod [-g <gid>] -o [-n <name>] <group-name> Table 4.9 describes the groupmod command options.
The following example changes the engrg group GID from 200 to 2000: groupmod -g 2000 engrg Any files that had the group ownership of "engrg" are now without a group name. A long listing would show a group ownership of 200 on these files, the previous GID for the engrg group. The group 200 no longer exists on the system, so only the GID is displayed in a long listing. The /usr/sadm/bin/smgroup modify command is the command-line equivalent of the SMC tool for modifying an existing group. Deleting Group Accounts from the Command LineYou use the groupdel command to delete a group account from the local system. The syntax for the groupdel command is as follows: groupdel <group-name> The following example deletes the group named acct from the local system: groupdel acct The /usr/sadm/bin/smgroup delete command is the command-line equivalent of the SMC tool for deleting an existing group. |