The “finger” command refers to the “user information lookup” utility that shows all the available information about the logged-in users of the Linux local system. It displays the specified user home directory, log-in name, user name, default shell, and much more. This utility is also utilized to look up the remote system user’s details.
This guide will provide a deep insight into the main objective, working, and usage of the “finger” command line tool.
- Prerequisites: Install finger Command Line Tool
- How Does the “finger” Command Work?
- Get the Logged-in User Information
- Access the Specified user Information
- Hide the Plan/Project/PGP-Key Fields
- Create and Verify Project/PGP-Key/Plan Fields
Prerequisites: Install finger Command Line Tool
Linux, and its distributions generally do not offer the “finger” command by default. So, first, install it by typing the following command as per Linux distribution:
$ sudo dnf install finger #For Fedora $ sudo yum install finger #For RHEL/CentOs
In this scenario, we installed it into “Ubuntu 22.04” Linux distribution as shown in the image:
$ sudo apt install finger #For Ubuntu/Debian
How Does the “finger” Command Work?
The working of the “finger” command based on its generalized syntax:
$ finger [options] [login..]
The syntax is divided into three main sections:
- finger: Represents the “finger” command line tool
- options: Shows supported options associated with the “finger” command.
- login: Denotes the specified log-in user name.
To get a detailed view of the “finger” command, read put its man page that can be easily accessed by utilizing the following command:
$ man finger
Scroll down the page for more information or enter the “q” tab to exit it from the terminal.
Now, look at a list of practical examples to understand the working of the “finger” command through its supported arguments.
Example 1: Get the Logged-in User Information
Simply the “finger” command without passing any argument/flag just list down the currently logged-in user in the console:
The above output of the “finger” commands contains the following fields/columns:
- Login: Specifies the currently logged-in user “itslinuxfoss”
- Name: Identifies the “Full-name” of the user that is stored in the current system.
- Tty: Denotes the terminal type “tty2” of the system.
- Idle: Shows the time that how the system is being started.
- Login Time: Shows the “Login-time” of the current user.
- Office: Represents the user’s IP address/user hostname.
- Office Phone: Evaluate the “Office Phone” if it is defined during the creation of the user.
Example 2: Access the Specified user Information
The “finger” command also displays the account information of the particular data in the following way:
$ finger johnson
The “johnson” user information is displayed in “Login”, “Name”, “Directory”, “Shell” sections. Whereas the last three sections do not contain any information i.e “logged-in Time”, “Mail”, and “Plan”.
Note: The exact output of the particular user can be achieved through the “-l” flag of the “finger” utility. It also converts the user account information into a list format as shown in the above image:
$ finger -l johnson
Shows Output In Table Format
To organize the specified user information in the table format, use the “-s” flag of the “finger” command as it arranges the user information in various columns (Same as “finger” output):
$ finger -s johnson
Here the user “johnson” details have been displayed in the terminal.
Example 3: Hide the Specified User Plan/Project/PGP-Key Fields
In most cases, the user wants to hide the “Plan”, “PGP-key”, and “Project” field details for some reason. In such cases, the “-p” flag is used to hide it.
Suppose to omit the “Plan” field of “anna” user execute the following command:
$ finger -p anna
As the above command has hidden the “Plan” field of user “anna”.
Create a Project/PGP-Key/Plan Fields and Verify Through the finger Command
As the above user does not have any content in the “Plan”, “PGP-Key”, and “Project” keys. To create these fields associated with the currently logged-in user, use the following commands one by one in the terminal:
Create a Project
To create a project for the user “itslinuxfoss” run this command:
$ echo "Create the “calculator” application" > ~/.project
The “.project” file has been created for user “itslinuxfoss”.
Create a Plan
To create a plan for the user “itslinuxfoss” execute this command:
$ echo "Update System packages Daily" > ~/.plan
The “.plan” file has been created for user “itslinuxfoss”.
Create a PGP Key
To create a PGP-Key for the user “itslinuxfoss” enter this command:
$ echo "New PGP-Key" > ~/.pgpkey
The “.pgpkey” file has been created for user “itslinuxfoss”.
The “~/.plan”, “~/.project”, and “~/.pgpkey” files are created into the “itslinuxfoss” home directory. Execute the “finger” command to check these fields content associated with the “itsliunuxfoss” user:
$ finger -l
The output displays the content of the “plan”, “project”, and “PGP key” of user “itslinuxfoss”
In Linux and most of its distributions, an external command “finger” is utilized to check the Linux local/remote system user’s information. It is beneficial for the system administrator to view the information of system users. It also provides a wide range of options to optimize its output according to the requirements. This guide has briefly illustrated the purpose, working, and functionality of the “finger” command.