lchfn Command in Linux
The lchfn command is a Linux command that is used to change a userâs finger information, which is typically stored in the gecos field of the /etc/passwd file. This information includes details like the userâs full name, office location, and phone numbers.
When you run the lchfn command, it allows you to update these details interactively. If you donât specify a user, it will update the information of the current user. This command is useful for keeping user information up to date.
Table of Contents
Here is a comprehensive guide to the options available with the lchfn command −
- Installation of lchfn Command
- Syntax of lchfn Command
- lchfn Command Options
- How to Use lchfn Command in Linux?
Installation of lchfn Command
To install the lchfn command on various Linux distributions, you need to install the libuser package. Here are the commands for different Linux systems:
1. Ubuntu/Debian −
sudo apt install libuser
2. Fedora −
sudo dnf install libuser
3. CentOS/RHEL −
sudo yum install libuser
4. Arch Linux −
sudo pacman -S libuser
5. OpenSUSE −
sudo zypper install libuser
Syntax of lchfn Command
The general syntax to use the lchfn command on Linux is as follows:
lchfn [options] [username]
Where:
- [options] are the flags you can use to specify which user information to change.
- [username] is the username of the account you want to modify. If you donât specify a username, the command will apply changes to the current user.
lchfn Command Options
Here are some different options that can be used with the Linux lchfn command:
Option | Description |
---|---|
-i, --interactive | Prompts for all questions during user database connection, regardless of default answers configured in libuser settings. |
-h, --help | Shows detailed help information for the command. |
-v, --version | Shows the version information of the command. |
How to Use lchfn Command in Linux?
As previously mentioned, the lchfn command is used to change the finger information of a user, which is typically stored in the âgecosâ field of the /etc/passwd file. The primary option available for this command is the -i or --interactive flag. This flag prompts the user to enter new information interactively.
The basic syntax to use the command with the flag is provided below:
sudo lchfn -i username
For example:
sudo lchfn -i ubuntu

After entering the command, you will be prompted to change various pieces of user information for the user "ubuntu". This command is used to modify the "finger" information, which includes details such as the userâs full name, office number, work phone, and home phone.
Here are the typical steps you might follow −
- Full Name − You will be asked to enter the full name of the user. If you donât want to change it, you can leave it blank and press Enter.
- Office − Next, you will be prompted to enter the office room number. You can leave it blank if you donât want to change it.
- Office Phone − You will be asked to enter the work phone number. You can skip this by pressing Enter.
- Home Phone − Finally, you will be prompted to enter the home phone number. You can leave this blank as well if you donât want to change it.
After you have entered the desired information or skipped the fields, the changes will be saved to the /etc/passwd file.

Conclusion
The lchfn command is a valuable tool for maintaining up-to-date user information on Linux systems. By allowing interactive updates to the gecos field in the /etc/passwd file, it ensures that user details such as full name, office location, and phone numbers are current.
In this tutorial, we provided a comprehensive overview of how to install, use, and utilize various options available with the lchfn command, making it easier for administrators to manage user information effectively.