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.
The finger is a user information lookup program in Linux. It is used to get system user details like the 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 a 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 Resolving Dependencies --> Running transaction check ---> Package finger.x86_64 0:0.17-40.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================= Installing: finger x86_64 0.17-40.el6 rhui-REGION-rhel-server-releases 22 k Transaction Summary ============================================================================================================================================================= Install 1 Package(s) Total download size: 22 k Installed size: 27 k Is this ok [y/N]: y Downloading Packages: finger-0.17-40.el6.x86_64.rpm | 22 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : finger-0.17-40.el6.x86_64 1/1 Verifying : finger-0.17-40.el6.x86_64 1/1 Installed: finger.x86_64 0:0.17-40.el6 Complete!
Finger command requires the 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 220.127.116.11 No mail. No Plan.
It displays –
- Login: Login id
- Name: Comment in /etc/passwd against that user
- Directory: Home directory of the user
- Shell: The user login shell
- Last login time and IP from where he/she was logged in
- Email status
- Plan : (the 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 the user has new mail
Finger command switches
Finger command supports a few switches. The above output without any switch is the same output for the switch
-l (multi-line listing). It also displays the content of the files .plan, .project, .pgpkey, and .forward from the user’s a home directory if they exist.
Another switch is -s which can be used for 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 the unknown device
- Write status: If write permission is denied
- login and idle time: If nonexistent
The last switch is -m which prevents user matching. Finger command matches the 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.