LinuxCommandLibrary

chfn

Change user information (finger command)

TLDR

Update a user's "Name" field in the output of finger

$ chfn [[-f|--full-name]] [new_display_name] [username]
copy

Update a user's "Office Room Number" field for the output of finger
$ chfn [[-o|--office]] [new_office_room_number] [username]
copy

Update a user's "Office Phone Number" field for the output of finger
$ chfn [[-p|--office-phone]] [new_office_telephone_number] [username]
copy

Update a user's "Home Phone Number" field for the output of finger
$ chfn [[-h|--home-phone]] [new_home_telephone_number] [username]
copy

SYNOPSIS

chfn [options] [username]

PARAMETERS

-f, --full-name NAME
    Sets the user's full name.

-r, --room-number NUMBER
    Sets the user's office room number.

-w, --work-phone NUMBER
    Sets the user's work phone number.

-h, --home-phone NUMBER
    Sets the user's home phone number.

-o, --other-info INFO
    Sets any other additional information.

-l, --list
    Displays the current finger information for the specified user (or the current user if none is specified).

username
    Specifies the login name of the user whose GECOS information is to be changed. Only the root user can specify a username other than their own.

DESCRIPTION

The chfn (change finger information) command is used to modify the GECOS field (also known as the "finger information" field) for a user's entry in the system's password file, typically `/etc/passwd`. This field traditionally stores details such as the user's full name, office room number, office phone number, and home phone number. The information provided via chfn is primarily displayed by the `finger(1)` command, which provides a lookup service for user details on a system. It can also be utilized by various mail clients or other system utilities that require a more descriptive identification of a user beyond their username.

When executed without options for specific fields, chfn interactively prompts the user for each piece of information (Full Name, Room Number, Work Phone, Home Phone). If a prompt is left blank, the existing value for that field is retained; if the field was previously empty, it remains empty. Users can typically change their own GECOS information without requiring superuser privileges. The `root` user, however, has the ability to change the GECOS information for any user on the system by specifying the target username as an argument. While the `finger` service and its associated information are less prevalent in modern, internet-facing systems due to privacy and security concerns, chfn remains a standard utility for managing this historical user data.

CAVEATS

The information set by chfn is stored in the GECOS field of the `/etc/passwd` file. This data is generally readable by all users on the system, which can pose privacy concerns.

The primary utility that consumes this information, the `finger(1)` service, is often disabled on modern multi-user systems due to these privacy implications and potential information leakage, making the information less useful in practice. Some systems might have stricter security policies or use alternative user management tools that could override or not fully utilize the GECOS field.

GECOS FIELD STRUCTURE

The GECOS field, which chfn modifies, is a comma-separated string in the fourth field of an `/etc/passwd` entry. The traditional order for these fields is Full Name, Room Number, Work Phone, Home Phone, and Other Information. chfn is designed to parse and update these specific sub-fields, maintaining the expected structure within the `/etc/passwd` file.

HISTORY

The chfn command has roots in early Unix systems, where it was a standard utility for users to update their personal information that could be queried by the `finger(1)` command. It was integral to the `finger` protocol, which provided a simple way to get details about users on a system or network.

On Linux, chfn is typically provided as part of the `shadow-utils` package (responsible for user and group account management) or sometimes `util-linux`. Its development has largely followed the evolution of Unix-like operating systems, adapting to modern file formats and security practices (e.g., handling `/etc/shadow` for passwords while still modifying `/etc/passwd` for GECOS). While its interactive nature remains, the overall usage has decreased significantly as the `finger` service itself has become less common due to privacy concerns and the move towards more distributed and less directly exposed user information services.

SEE ALSO

finger(1), passwd(5), usermod(8), chsh(1)

Copied to clipboard