chfn is a command-line utility in Linux that is used to change the user information associated with a specific user account. This information includes the user’s full name, office location, office phone number, and other details that are stored in the system password file.
To use chfn, you will need to have root privileges or be the owner of the user account that you want to modify. You can then use the following command syntax to change the user information:
# chfn [options] username
This command will prompt you to enter the new user information, which you can enter by typing or pasting the information at the prompt. When you are finished, you can press Enter to save the changes.
If you encounter the below error while running the command chfn:
chfn: command not found
you may try installing the below package as per your choice of distribution:
Distribution | Command |
---|---|
Debian | apt-get install passwd |
Ubuntu | apt-get install passwd |
Alpine | apk add util-linux |
Arch Linux | pacman -S util-linux |
Kali Linux | apt-get install passwd |
CentOS | yum install util-linux-ng |
Fedora | dnf install util-linux-user |
OS X | brew install util-linux |
Raspbian | apt-get install passwd |
chfn includes several options that allow you to customize the way it modifies the user information. For example, you can use the -f option to specify the full name, the -o option to specify the office location, and the -p option to specify the office phone number.
For example, to change the full name of the user john to John Smith, you can use the following command:
# chfn -f "John Smith" john
chfn Command Examples
1. Update a user’s “Name” field in the output of `finger`:
# chfn -f new_display_name username
2. Update a user’s “Office Room Number” field for the output of `finger`:
# chfn -o new_office_room_number username
3. Update a user’s “Office Phone Number” field for the output of `finger`:
# chfn -p new_office_telephone_number username
4. Update a user’s “Home Phone Number” field for the output of `finger`:
# chfn -h new_home_telephone_number username