5 UNIX / Linux chfn Command Examples to Change User Finger Info

chfn stands for Change Finger.

This command is used to change finger information of the user.

1. Before Changing User’s Finger Info

You’ll use finger command to display information about the users. As sown below, it will display the login name, Real Name, Home Directory, Last login, etc of the users.

$ finger ramesh
Login: ramesh                           Name:
Directory: /home/ramesh                 Shell: /bin/bash
On since Sat Oct 19 07:38 (PDT) on pts/0 from 192.168.1.2
New mail received Sat Oct 19 03:08 2013 (PDT)
     Unread since Tue May 28 15:31 2013 (PDT)
No Plan.

By default some of these information are pulled from the /etc/passwd file for the corresponding user.

$ grep ramesh /etc/passwd
ramesh:x:500:500::/home/ramesh:/bin/bash

In the above example, the user’s finger information is not set properly. In the next example, we’ll change this information and see how the above output changes.

2. Default chfn Example

Any user who is logged into the terminal, can change their own finger information.

By default when you execute chfn command without any argument, it will change the finger information for the current logged in user. It will ask for your password before changing the information. As part of the finger information, it will prompt for Full Name, Office Location, Office Phone and Home Phone.

$ chfn
Changing finger information for ramesh.
Password:
Name []: Ramesh Natarajan
Office []: 3rd floor room 313
Office Phone []: 111-222-3333
Home Phone []: 444-555-6666
Finger information changed.

Once the finger information is changed, if you execute the finger command, you’ll see the above information set properly.

$ finger ramesh
Login: ramesh                           Name: Ramesh Natarajan
Directory: /home/ramesh                 Shell: /bin/bash
Office: 3rd floor room 313, 111-222-3333        Home Phone: 444-555-6666
On since Sat Oct 19 07:38 (PDT) on pts/0 from 192.168.1.2
New mail received Sat Oct 19 03:08 2013 (PDT)
     Unread since Tue May 28 15:31 2013 (PDT)
No Plan.

The full-name, office location, office phone and home phone are stored in the 5th field of the /etc/passwd file for the corresponding user as shown below.

$ grep ramesh /etc/passwd
ramesh:x:500:500:Ramesh Natarajan,3rd floor room 313,111-222-3333,444-555-6666:/home/ramesh:/bin/bash

3. Change Finger Info for Other Users

Only root can change finger information for other users. For example, when ramesh tries to change finger information for John, it will give permission denied error message as shown below.

$ chfn john
chfn: Permission denied

But, as root you can change the finger information for john.

# chfn john
Changing finger information for john.
Name []:
..

4. Change Name and Office Location

You can also change either Name, or Office Location using the options as explained below.

Use option -f to change only the Full Name as shown below.

$ chfn -f "Ramesh N"
Changing finger information for ramesh.
Password:
Finger information changed.

$ finger ramesh
Login: ramesh                           Name: Ramesh N
Directory: /home/ramesh                 Shell: /bin/bash
Office: 3rd floor room 313, 111-222-3333        Home Phone: 444-555-6666
On since Sat Oct 19 07:38 (PDT) on pts/0 from 192.168.1.2
New mail received Sat Oct 19 03:08 2013 (PDT)
     Unread since Tue May 28 15:31 2013 (PDT)
No Plan.

use option -o to change only the Office location as shown below.

$ chfn -o "4th floor room 414" ramesh
Changing finger information for ramesh.
Password:
Finger information changed.

$ finger ramesh
Login: ramesh                           Name: Ramesh N
Directory: /home/ramesh                 Shell: /bin/bash
Office: 4th floor room 414, 111-222-3333        Home Phone: 444-555-6666
On since Sat Oct 19 07:38 (PDT) on pts/0 from 192.168.1.2
New mail received Sat Oct 19 03:08 2013 (PDT)
     Unread since Tue May 28 15:31 2013 (PDT)
No Plan.

5. Change Phone Numbers Only

You can also change only the phone numbers in the user’s finger information using the options explained below.

Use option -p to change only the office phone number as shown below.

$ chfn -p "111-111-1111" ramesh
Changing finger information for ramesh.
Password:
Finger information changed.

$ finger ramesh
Login: ramesh                           Name: Ramesh N
Directory: /home/ramesh                 Shell: /bin/bash
Office: 4th floor room 414, 111-111-1111        Home Phone: 444-555-6666
On since Sat Oct 19 07:38 (PDT) on pts/0 from 192.168.1.2
New mail received Sat Oct 19 03:08 2013 (PDT)
     Unread since Tue May 28 15:31 2013 (PDT)
No Plan.

Use option -h to change only the home phone number as shown below.

$ chfn -h "222-222-2222" ramesh
Changing finger information for ramesh.
Password:
Finger information changed.

$ finger ramesh
Login: ramesh                           Name: Ramesh N
Directory: /home/ramesh                 Shell: /bin/bash
Office: 4th floor room 414, 111-111-1111        Home Phone: 222-222-2222
On since Sat Oct 19 07:38 (PDT) on pts/0 from 192.168.1.2
New mail received Sat Oct 19 03:08 2013 (PDT)
     Unread since Tue May 28 15:31 2013 (PDT)
No Plan.