Learn how to get user details by using finger command in Linux. List of switches for finger command and list of parameter information in this article.
Finger is a user information lookup program in Linux. It is used to get system user details like user, home directory, last login, user shell etc. This command is useful to see these parameters which otherwise you have to look under /etc/passwd and last login records.
Sometimes you will not find finger command in your out of box distribution. You can install finger package and proceed to use this command. Sample output of installation on Redhat for your reference.
# yum install finger
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos, security
Setting up Install Process
epel/metalink | 15 kB 00:00
epel | 4.3 kB 00:00
epel/primary_db | 5.9 MB 00:04
rhui-REGION-client-config-server-6 | 2.9 kB 00:00
rhui-REGION-rhel-server-releases | 3.5 kB 00:00
rhui-REGION-rhel-server-releases/primary_db | 56 MB 00:00
rhui-REGION-rhel-server-releases-optional | 3.5 kB 00:00
rhui-REGION-rhel-server-releases-optional/primary_db | 5.4 MB 00:00
rhui-REGION-rhel-server-rh-common | 3.8 kB 00:00
--> Running transaction check
---> Package finger.x86_64 0:0.17-40.el6 will be installed
--> Finished Dependency Resolution
Package Arch Version Repository Size
finger x86_64 0.17-40.el6 rhui-REGION-rhel-server-releases 22 k
Install 1 Package(s)
Total download size: 22 k
Installed size: 27 k
Is this ok [y/N]: y
finger-0.17-40.el6.x86_64.rpm | 22 kB 00:00
Running Transaction Test
Transaction Test Succeeded
Installing : finger-0.17-40.el6.x86_64 1/1
Verifying : finger-0.17-40.el6.x86_64 1/1
Finger command requires username as an argument. Without any switch finger shows below details.
# finger shrikant
Login: shrikant Name: Shrikant Lavhate
Directory: /home/ec2-user Shell: /bin/bash
On since Wed Jul 5 00:31 (EDT) on pts/0 from 18.104.22.168
It displays –
- Login : Login id
- Name : Comment in /etc/passwd against that user
- Directory : Home directory of user
- Shell : User login shell
- Last login time and IP from where he/she was logged in
- Email status
- Plan : (content of .plan file in user’s home directory)
Email status can be one of the below –
- No Mail. : if there is no mail at all
- Mail last read DDD MMM ## HH:MM YYYY (TZ) : if the person has
looked at their mailbox since new mail arriving
- New mail received … : Same as above
- Unread since … : if user have new mail
Finger command switches
Finger command supports few switches. The above output without any switch is same output for switch -l (multi-line listing). It also displays content of the files .plan, .project, .pgpkey and .forward from the
user’s home directory if they exists.
Another switch is -s which can be used to more information like terminal name, write status, idle time, login time and contact details etc.
# finger -s shri
Login Name Tty Idle Login Time Office Office Phone
shri Shrikant Lavhate * * No logins
In this output you can see * for :
- terminal : When unknown device
- Write status : If write permission is denied
- login and idle time : If nonexistent
Last switch is -m which prevents user matching. Finger command matches supplied user name in userid and user comment details. To avoid matching it in comment details and only check in user ids this switch can be used.
Finger can even be used to lookup remote user information by using user@host format.