Previous Table of Contents Next

Module 15
chfn (BSD)


The external chfn command allows you to change the information field in the system password file /etc/passwd. An alternative command to chfn is passwd -f. Either of these commands displays the current information stored in the fifth field of the /etc/passwd file. This information is referred to as the GECOS information. The fifth field consists of several subfields, which are comma separated. You are prompted for new information to replace each of these subfields. The fifth field usually includes the following subfields for each user:

+ "real life" name
+ office room number
+ office phone number
+ home phone number

The prompt contains the existing value of the subfields within square brackets ([subfield value]). The existing value is retained by simply pressing Return. If you want the field to be empty, type the word "none" at the prompt. Phone numbers may or may not contain hyphens.

It is advisable to run the finger command after running chfn or passwd -f.

The super-user can change any user's GECOS information. You can only change your own GECOS information as a normal user. It is a description of the user of the account. The finger program displays this information.


Following is the general format of the chfn command.

     chfn [ user_name ]


     passwd -f [ user_name ]


The following list describes the option used to control passwd to function like chfn.

-f Informs passwd to execute the chfn function to change the GECOS information stored in the /etc/passwd file.


The following argument may be used to change how chfn functions.

user_name Causes chfn to change the information for the specified user instead of the user executing chfn.


Refer to the passwd and finger commands described in modules 100 and 56.


The chfn command updates the information in the fifth field of the /etc/passwd file. The fields in the /etc/passwd file are separated by colons.


You will need to use the chfn command to keep the information pertaining to your office room number and phone numbers updated.


In this activity you use the chfn command to change your office phone number. Begin at the shell prompt. The information in the prompts will be different for each user's login. Use your actual office phone number in the following command.

1.  Type chfn and press Return. You will be prompted as follows; press Return after each prompt that you do not want to update.
     cj> chfn
     Name [David Hancock]: <CR>
     Room Number (Exs: 597E or 197C) [69]: <CR>
     Office Phone (Ex: 1632) [474]: 483 <CR>
     Home Phone (Ex: 987532) [555-1212]: none <CR>
2.  Turn to Module 38 to continue the learning sequence.

Previous Table of Contents Next