The passwd File

Every user on a Linux system has an entry in the /etc/passwd file. To see what accounts exist on a Linux system, just look inside that file. Listing 3.8 is the passwd file from our sample Red Hat system.

Listing 3.8: A Sample /etc/passwd File

# cat /etc/passwd root:gvFVXCMgxYxFw:0:0:root:/root:/bin/bash bin:*:1:1:bin:/bin:

sync:*:5:0:sync:/sbin:/bin/sync shutdown:*:6:0:shutdown:/sbin:/sbin/shutdown halt:*:7:0:halt:/sbin:/sbin/halt mail:*:8:12:mail:/var/spool/mail:

uucp:*:10:14:uucp:/var/spool/uucp:

operator:*:11:0:operator:/root:

games:*:12:100:games:/usr/games:

gopher:*:13:30:gopher:/usr/lib/gopher-data:

craig:6VKY34PUexqs:500:100:Craig Hunt:/home/craig:/bin/bash sara:niuh3ghdj73bd:501:100:Sara Henson:/home/sara:/bin/bash kathy:wv1zqw:502:100:Kathy McCafferty:/home/kathy:/bin/bash david:94fddtUexqs:503:100:David Craig:/home/david:/bin/bash becky:tyebwo8bei:500:100:Rebecca Hunt:/home/becky:/bin/bash

Most of these accounts are included in the passwd file as part of the initial installation; only the last five entries in Listing 3.8 are real user accounts added by the system administrator. The first entry is the root account for the system administrator, but most of the others are special accounts created for programs that need to control processes or that need to create and remove files.

Each /etc/passwd entry follows the usenpasswordUIDGIDxommenthomeshell format, where

• user is the username. It should be no more than eight characters long, and should not contain capital letters or special characters. kristin is a good username.

• password is the encrypted password of the user. Of course, you don't actually type an encrypted password here. The encrypted password is stored here by the passwd command. If you use the shadow password file, and most Linux distributions do, the encrypted password will not actually appear here. Instead, the password will be stored in /etc/shadow. See Chapter 12 for a description of the shadow password file.

• UID is the numeric user ID for this user account.

• GID is the numeric group ID of the primary group of this user.

• comment is text information about the user. At a minimum, you should have the user's first and last names. Some people like to include the user's telephone number and office room number. For historic reasons, this field is sometimes called the GECOS field.

• home is the user's home directory.

• shell is the login shell for this user.

Almost all of the information needed to create a user account appears in the passwd file. The next few sections examine some of this information in more detail.

Was this article helpful?

0 0

Post a comment