Solaris 8 User Administration Tools
- Account Configuration Files
- Admintool
- User Administration Shell Commands
- Shells
- User Account Commands
- Chapter Summary
- Test Yourself
After completing this chapter, you'll be able to
Identify the following login procedures: log into a system, log out of a system, and change login passwords.
State the command used to identify which users are currently logged into the system.
State the steps required to create user accounts on the local system using the admintool utility.
State the command syntax to add, modify, or delete user/group accounts on the local system with the useradd, groupadd, usermod, groupmod, userdel, or groupdel commands.
Given a user's login shell, list the shell initialization files used to set up a user's work environment at login.
To fulfill these objectives, this chapter discusses:
User account configuration files;
Adding, modifying, and deleting user accounts with Admintool;
Adding, modifying, and deleting user accounts with shell commands;
User shells; and
User account commands.
5.1 Account Configuration Files
Three principal files define the identity of a user account: the password file, the shadow file, and the group file.
The Password File
The password file contains the basic identifying information for each user allowed to access a system. The system location of the password file is /etc/passwd. The format of the password file is:
username:password:uid:gid:gcos-field:home-dir:login-shell
These fields are:
usernamethe name that identifies the user account.
passwordin Solaris 8 an "x" in this field signifies that the corresponding shadow file contains the encrypted password string.
uidthe unique numerical ID assigned to the account. The maximum value for UID is 2147483647, but administrators are urged to use values less than 60,000 to ensure compatibility with all of the tools that are used to manage accounts or display information that includes usernames.
gidthe primary (default) numerical group ID assigned to the account. Like the UID field, the maximum value for GID is 2147483647, but a maximum of 60,000 is preferable.
gcos-fieldthis is the user's real name (the term "gcos-field" is the historical term for this field).
home-dirthe directory where the user is placed after logging in; this usually contains the user's own files and directories.
login-shellthe initial shell that is started on behalf of the user upon logging in. If this field is blank, then /usr/bin/sh is used.
The password file can be read by anyone on the system. There is no information that must be kept secret in this file. A sample password file looks like this:
root:x:0:1:Super-User:/:/sbin/sh daemon:x:1:1::/: bin:x:2:2::/usr/bin: sys:x:3:3::/: adm:x:4:4:Admin:/var/adm: lp:x:71:8:Line Printer Admin:/usr/spool/lp: uucp:x:5:5:uucp Admin:/usr/lib/uucp: nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico listen:x:37:4:Network Admin:/usr/net/nls: pete:x:100:4:Peter Gregory:/export/home/pete:/bin/sh nobody:x:60001:60001:Nobody:/:
Fields in the password file are delimited by colons (":"), and blank fields are signified by two adjacent colons ("::"). For instance, note that the account name field for daemon is blankjust two colons. Also, daemon has no shell entry, so the last character for daemon is the colon delimiter.
The colon delimiter is also used in the shadow and group files, which are discussed in a later section.
It is possible and permissible to create more than one username in the password file with the same UID. Each username will have its own unique password. However, tools such as ls and ps, when used with options displaying username, will display the first username found in the password file matching the UID.
When a new account is added, changed, or removed with the useradd, usermod, or userdel commands (which are discussed later in this chapter), the system creates a backup copy of the password file, called /etc/opasswd.
The Shadow File
The shadow file contains each user account's encrypted password, as well as specific per-account parameters governing "password aging." The system location of the shadow file is /etc/shadow. The format of the shadow file is:
username:password:lastchg:min:max:warn:inactive:expire:flag
These fields are:
usernamethis is the same username found in the password file.
passworda 13-character encrypted password. If this field contains a lock string (e.g., "locked" or "NP"), the account is inaccessible; if blank, the account has no password.
lastchgdate of last password change (literally the number of days between January 1, 1970, and the date the password was last changed).
minminimum number of days allowed before the password can be changed.
maxmaximum number of days allowed before the password expires.
warnthe number of days prior to expiration that the user is warned.
inactivethe number of days of inactivity allowed for the account before the account is automatically locked.
expirethe date when the user account is deactivated.
flaga field reserved for future use.
The shadow file is restricted so that only the system administrator can read it. This is because an intruder could perform a "dictionary attack," using guessable passwords in an attempt to determine the passwords for one or more accounts. Programs that "crack" account passwords are available for this purpose; thus, the shadow file is not publicly readable.
A sample shadow file looks like this:
root:Pe0iQfp2LcAig:10528:::::: daemon:NP:6445:::::: bin:NP:6445:::::: sys:NP:6445:::::: adm:nIP3GPx2FIZYQ:11053:::::: lp:NP:6445:::::: uucp:NP:6445:::::: nuucp:NP:6445:::::: listen:*LK*::::::: pete:GSSUYVrJ8EKyA:11055:::::: nobody:NP:6445::::::
Note that some of the accounts in the example shadow file have "NP" ("no password") or "*LK*" (locked) in them. These are just two ways of signifying that the accounts are locked against login. There is nothing really magic about "NP" or "*LK*"they are just one way of easily showing that these accounts are locked and going to stay that way. You could put other text in the password field to suit your needs; for instance, a helpdesk ticket number or a date.
When a user changes his or her password, the system creates a backup copy of the shadow file, called /etc/oshadow. This also occurs if root changes a user's password.
Exam Notes
Think About It . . .
Why are encrypted passwords found in /etc/shadow and not in /etc/passwd?
For many commands (ps, ls, etc.) to work properly, /etc/passwd must be world readable. Prior to the use of /etc/shadow, all users' encrypted password strings were also publicly readable. This gave people with "password cracking" programs an opportunity to discover other users' passwords. By moving the encrypted password strings to /etc/shadow (which can be read only by root), the ability to access encrypted passwords is eliminated.
First, a bit of history. Older versions of UNIX did not have a shadow file; instead, the encrypted password string was found in the password file, in the second field that is usually filled with an "x" in Solaris. Solaris still supports the encrypted password appearing in the password file, although this is not advisable, since the password file is publicly readable.
Older versions of UNIX with no shadow file also had no password-aging capability.
The Network Information System (NIS) subsystem was designed around the old shadow-less architecture; this explains why NIS has no shadow map, nor does it support password aging.
The Group File
The group file contains a listing of all of the groups on the system, along with each group's numeric groupid and a list of each of the usernames that are secondary members of each group. The location of the group file is /etc/group. The format of the group file is:
groupname:password:gid:user-list
These fields are:
groupnamethis is the name of the group.
passwordthis is an optional password for the group.
gidthe unique numerical ID assigned to the group. The maximum value for GID is 2147483647, but administrators are urged to use values less than 60,000 to ensure compatibility with all of the tools that are used to manage accounts or display information that includes group names.
user-lista comma-separated list of users allowed in the group. These groups are users' secondary group IDs.
A sample group file follows.
root::0:root other::1: bin::2:root,bin,daemon sys::3:root,bin,sys,adm adm::4:root,adm,daemon uucp::5:root,uucp mail::6:root tty::7:root,tty,adm lp::8:root,lp,adm nuucp::9:root,nuucp staff:GSSUYVrJ8EKyA:10:pete daemon::12:root,daemon sysadmin::14: nobody::60001: noaccess::60002: nogroup::65534:
Note the password field in the group "staff." Groups can be password protected by putting a password string into the password field. Note, though, that this is a completely manual process; there are no tools provided to put the group password in for you.
Hint: You can take a password string from the shadow file and use the vi editor to splice it into the group file. The group password will be the same as the account password from the shadow entry where you took the password string.
When a group is password protected, anyone who is not a member of the group will be challenged for the group's password when they have entered the newgrp command.
Primary and Secondary Groupids
Each user account has one primary groupidthis is the group defined in the password file. When a user logs on, this is his or her associated groupid.
Each user account also has zero or more secondary groupids. A user's secondary groups are those group entries that include the username in their lists of members.
There are some useful limitations of groupids. For example, each user account can be in no more than 16 groups, and a line in the group file cannot exceed 512 characters (including the newline character).
What happens if you need to add so many members to a group that you exceed the 512-character entry limit? You simply create another duplicate group entrysame name and group numberand list the additional members there.
The primary and secondary groupids directly impact file system access permissions, which is explored fully in Chapter 10.
Exam Notes
Think About It . . .
What would be the effect if a username were added to a group file entry when that group was the user's primary group?
The additional entry would have no effect, since the user is already configured for the primary group membership in the /etc/passwd file.
The Root Account
The root account has special privileges on a system: Root is permitted to read and write every file on a system, regardless of the file's ownership and permission settings. System administrators log in with the root account so that they can perform administrative tasks.
The root account gets its power and privilege from the value of its user number: Root is user number zero, defined in the password file.
Exam Notes
Think About It . . .
What would be the effects of changing an ordinary user's user number to zero? What advantage might there be of putting root's entry at the end of the passwd file (instead of the beginning)?
Changing an ordinary user's user number to zero gives the user root privileges.
One advantage of putting root at the end of the password file is that if an intruder is able to modify the password file to give another user root privilege (see the first question here), then output from commands such as ls and ps would show that other user as the owner of root processes and files.