finger command in Linux | Explained

Linux is a multi-user operating system where multiple users can access and utilize the system resources at the same time. Sometimes as per requirements, the user needs to know about the details of all the existing users on the system to change their permissions, remove their data, set some rules for them, and much more. In such scenarios, Linux provides a powerful command line utility named the “finger” command. It performs this task for both local users and those who are connected to the system remotely. 

Quick Outline

  1. What is finger Command?
  2. How to Install the finger Command in Linux?
  3. How Does finger Command Work in Linux?
  4. How to Use finger Command in Linux?
  5. How to Uninstall/Remove finger Command From Linux?
  6. What is the Alternative to Linux finger Command?
  7. Conclusion

Let’s first start with the basics of the finger command.

What is finger Command?

Linux “finger” command shows the information of the system’s users. This includes the login name and time, full or real name, idle time, terminal type, office location, and phone number. In addition, the “finger” command also looks up the users on the remote system. That’s why it is known as the “user information lookup” utility. 

How to Install the finger Command in Linux?

The “finger” command is not present by default in the Linux operating system. It is an external utility, and the user needs to install it using the below-stated commands based on the Linux distribution:

On Debian/Ubuntu

To install “finger” on Debian or Ubuntu Linux distribution, use its default “apt” package manager along with the administrative privileges:

sudo apt install finger

Output

The “finger” command line utility has been successfully installed in the current Ubuntu system:

A screenshot of a computer

Description automatically generated

On RHEL/CentOS

For RHEL or CentOS-based Linux distributions, use the “yum” package manager to install the “finger” utility:

sudo yum install finger

On Fedora

To install the “finger” command line utility on the Fedora Linux distro, utilize the below-stated “dnf” installation command:

sudo dnf install finger

Once the installation of the “finger” command is completed successfully, move on to its working.

How Does finger Command Work in Linux?

The “finger” command works on the generalized syntax. It tells the “shell(Linux command line interpreter)” to get the user’s information based on it.

Syntax

finger [-lmsp] [user ...] [user@host ...]

In the above syntax:

  • [-lmsp]: These are the supported options of the “finger” command that display its output in different formats.
  • user: It specifies the local user login name whose information needs to be retrieved.
  • user@host: It denotes the user information in a long format on the remote host. The remote host refers to a device in another location that is accessed over the internet to perform remote operations.

Supported Options of finger Command

The supported options of the “finger” command allow the users to get the output in different formats based on their requirements. Each option changes the format of the “finger” command output according to its specified functionality. 

The given table shows all the supported options of the “finger” command along with their description:

OptionsDescription
-sIt shows the default output of the “finger” command that includes the user’s login name and time, full or real name, idle time, terminal type, office location, and phone number.
-lIt specifies the output of the “finger” command in a multi-line format. Its output contains all the information retrieved by the “-s” flag, the content of the “.plan”, “.project”, and “.pgpkey”  files from the user’s home directory, and the home phone number, mail status, as well as a login shell.
-mIt restricts the “finger” command to search the user exclusively based on its login name, not a real or full name. It only displays the information of the user whose login name is exactly matched with the specified username.
-pIt prevents the finger command to not displaying the “.plan”, “.project”, and “.pgpkey”  files content. 

After getting the basics and working of the “finger” command, let’s jump into its usage.

How to Use finger Command in Linux?

Administrators mostly use the “finger” command to get the information of all the users that use the current Linux system. This section carries out all the possible use cases that perform this task practically.

Let’s first start with the default behaviour of the “finger” command.

Example 1: Default Behaviour of finger Command

By default, the “finger” command shows the currently logged-in user information. Here is its practical implementation:

finger

Output

The execution of the “finger” command without any supported option displays the currently logged-in user information in the following fields:

The descriptions of all the above fields are listed below:

  • Login: It displays the user login name/username which is “linux” in this scenario.
  • Name: It denotes the full or real name of the logged-in user. In this scenario, it is the same as the user’s login name.
  • Tty: It tells the terminal type which may be of two types:
  • pts: The “pts” denotes the remote login/SSH connection.
  • tty: The “tty” refers to the direct connection to the system. In the current output, the “tty2” refers to the virtual terminal session. 
  • Idle: It shows the time in which the system does not do any productivity (resources are free). It can be in 3 formats:
  • single plain digit: It refers to “minutes”.
  • colon(:): It corresponds to “hours and minutes”
  • d: It shows the number of “days”. In the current output, the “22” a single plain digit refers to minutes.
  • Login Time: It displays the login time along with the date.
  • Office: It refers to the user’s office location including the name or number of the room. Now, the finger command displays the IP address of the machine in place of it from which the account is logged in. 
  • Office Phone: It tells the office phone number of the logged-in user that is not recorded nowadays. That’s why this field is mostly blank.

Example 2: Use the finger Command to Get Particular User Information

To get the user information specify its name after the “finger” command in this generalized way:

finger username

In this example the information of username “anna” is retrieved through the “finger” command:

finger anna

Output

It can be observed that the output of the above command contains some additional information when it is executed with the specified user: 

In the above output, the “Login” and “Name” fields work the same as in the logged-in user use case. However, the description of the additional fields is stated below:

  • Directory: It specifies the home directory of the targeted user.
  • Shell: It tells the shell used by the specified user. In this output, the given user is using the “bash” shell.
  • On Since: It displays the logged-in time of the given user including the tty and Ip address. According to the above output, the specified user is never logged in to the system.
  • Mail: It shows the user’s unread mail. If all the mails have been checked by the user, then it shows the time on which it is shown. The current user has no mail.
  • Plan: It shows the content of the “.plan” and “.project” files if they exist in the user’s home directory. These files store a little bit of information about the user plan and project. These files are very rarely used nowadays. In the above output, the given user has no plan.

Example 3: Use the finger Command to Get User Information via Short Name

The “finger” command is “case insensitive” and does not require the full name of the user. It matches the specified username that is passed as its argument with the login and the real name of all the users. If it finds any of the users that contain the argument, then it retrieves its information. 

That’s why the user can search the targeted user information via the “finger” command by specifying its short name like this:

finger Henry

Output

The output shows the “Henry” user’s information whose real anime is “Henry Johnson”:

Example 4: Use the finger Command With the “-l” Flag to Display Complete User Information

The exact user’s information achieved in Example 2 can also be retrieved via the “-l” flag of the “finger” command. This flag shows the given user information in multi-line formats containing the same information fields as in the user:

finger -l linux

Output

The below output contains the complete information of specified user “linux”:

Example 5: Use the finger Command With the “-p” Flag to Hide the Plan, Project, PGP Keys

To exclude the “plan” field including the “project” and “pgp key” of the specified user, use the “-p” flag of the “finger” command. This flag removes all the fields from the output that started with the “p” keyword:

finger -p linux

Output

The above “finger” command now excludes the “plan” field of the specified user from the output:

Example 6: Use the finger Command With the “-s” Flag to List User Information in Columns

The “finger” command by default shows the logged-in user information column-wise. Each column or field contains information based on its name. 

The same functionality can be achieved for a specific user with the help of the “-s” flag of the “finger” command. It sorts the specified user information in specific sections according to column names:

finger -s linux

Output

The below output contains the “linux” user information in the terminal column-wise:

Example 7: Use the finger Command With the “-m” Flag to Prevent Full Name 

It can be analyzed in Example 3, that the “finger” command matches any of the specified arguments with the “Login” and the full “Name” fields. It is not suitable in situations where the specified argument(username) exists in the full name of another user. 

Suppose we have two users whose real names are “herry” and “anna herry”. If we want to get the information of only the “herry” user, then the “finger” command will show both the “herry” and “anna herry” information. This is because the specified username is also matched with the real name of “anna herry”:

Here is the practical implementation of the above-discussed scenario:

finger herry

Output

As discussed, the above “finger” command output displays both “herry” and “anna user” information:

To avoid such cases, use the finger command followed by the “-m” flag that prevents the username matching. It matches the specified argument only with the login name in this way:

finger -m herry

Output

The below output now only shows the “herry” user information because of the usage of the “-m” flag with the “finger” command:

How to Create a Plan, Project, and PGP Key For a User and Read Them Via the “finger” Command?

It can be observed that in all the above “finger” command examples, there is no plan field including the project and PGP key. If these fields do not exist by default, then the user can create them manually. 

This section creates these fields associated with the currently logged-in user using the following commands: “cat” and “echo”:

Create a Plan For the User

In Linux, the “plan” is a text file that contains the user’s personal information and goals such as office hours, schedules, and much more. It is represented as a “.plan” file and is in the user’s home directory. The below “cat” and “echo” commands create it for the currently logged-in user:

Method 1: Using the “cat” Command

Execute the below-stated “cat” command followed by the “>(Redirection)” operator and the “.plan” file name. After its execution write the text inside this file and press “Ctrl + D” to “save” and “exit” it:

cat > .plan

Output

The output shows that the “.plan” file has been created successfully having the following content:

Open User’s Plan

Use the “finger” command followed by the currently logged-in user to open the “.plan” when it is created successfully:

finger linux

Output

The “finger” command output now contains the plan of the specified user:

Method 2: Using “echo” Command

The “.plan” of the user can also be created through the Linux echo” command. For this purpose, specify its content after the “echo” command. Next, use the “>(Redirection)” operator along with the “.plan” location which is the user’s home directory in this way:

echo "Update System Packages" > ~/.plan

In the above command, the “~/” refers to the current working directory(cwd) which is “/home” in this scenario.

Output

The successful execution of the above command confirms that the “.plan” of the currently logged-in user has been created:

For more verification use the “finger” command followed by the specified “username”:

finger linux

Output

The “finger” command verifies the creation of “.plan” by displaying its updated content on the terminal:

Create a Project For the User

The “.project” is like “.plan” but contains the description of the defined goals. Like “.plan”, the “.project” does not mean file extension as it denotes the file name. Let’s create it for the currently logged-in user via both the “cat” and “echo” commands:

Method 1: Using the “cat” Command

Specify the “.project” file name along with the “>(Redirection)” operator and the “cat” command like this:

cat > .projectfinger linux

Output

It can be analyzed that the “finger” command reads the “.project” file content and displays it in the “Project” field:

Method 2: Using “echo” Command

The creation of the “.project” file using the “echo” command is the same as the “.plan” file: 

echo "A new Linux project" > ~/.projectfinger linux

Output

The output verifies the creation of the currently logged-in user “Project” via the “finger” command:

Create a PGP-Key For the User

Now, create a “PGP(Pretty Good Privacy)-key” for the specified user. This is a public key that encrypts the emails, user messages, text-files content, and directories for secure data communication. Its creation follows the same “cat” and “echo” commands used for the “.plan” and “.project” files.

Method 1: Using the “cat” Command

Run the “cat” command along with the “>” operator and the “.pgpkey” file name to create a “PGP-key” for the currently logged-in user:

cat > .pgpkeyfinger linux

Output

The “PGP” key has been added to the “.pgpkey” file. Moreover, the “finger” command also displayed this key in the “PGP key” field of the given user’s information:

Method 2: Using echo Command

In this method, type the “PGP-key” right after the “echo” command and then specify the “>” operator and the “.pgpkey” file name:

echo "qwsrty6543" > ~/.pgpkeyfinger linux

Verification

The below output first creates the “.pgpkey” file having the given “PGP-key” and then shows it using the “finger” command:

Let’s remove the finger command after its usage.

How to Uninstall/Remove finger Command From Linux?

When the usage of the “finger” command is done, the user can remove it from the Linux system. The removal of this command is quite simple and straightforward. It can be easily achieved using the default package managers of Linux distros, the same as its installation. 

On Debian/Ubuntu

To remove the “finger” command from Debian/Ubuntu-based Linux distributions, specify the “autoremove” keyword along with the “apt” and the administrative privileges:

sudo apt autoremove finger # Remove finger utility and configuration files
sudo apt purge finger     # Remove finger utility, packages, configuration files

Output

In this scenario, the “finger” command has been successfully removed from the current working system Ubuntu:

On RHEL/CentOS

For RHEL/CentOS Linux distros, use the “remove” keyword for the removal of the “finger” command right after the “yum” package manager:

sudo yum remove finger

On Fedora

On Fedora-based Linux distributions, use the below-stated removal command that uses the default package manager “dnf” to uninstall the “finger” command:

sudo dnf remove finger

What is the Alternative to Linux finger Command?

Linux offers a built-in “pinky” command that works the same as the “finger” command. It is the pre-installed lightweight command that gives detailed information about the logged-in user by default. If any user specifies along with it as an argument, then it provides whose information. The user can also call it a “user information lookup” program.

Syntax

The “pinky” command follows a similar structure as the “finger” lookup utility

pinky [OPTION]... [USER]...

In the above syntax the “[OPTION]” denotes the range of supported options of the “pinky” command. Next, the “[USER]” specifies the username whose information needs to be retrieved.

Supported Options of “pinky” Command

To get all the supported options of the “pinky” lookup utility execute the below-stated “–help” command:

pinky --help

Let us follow an example for basic understanding:

Example: Default Behaviour of “pinky” Command

The “pinky” command without specifying any supported option displays the recent or last logged-in user information:

pinky

Output

The output of the “pinky” command shows detailed information about the logged-in users including the fields “When” and “Where” they logged in:

That is all about finger command in Linux.

Conclusion

The Linux “finger” command line utility looks up the information of the user on the local or remote system. By default, this information is displayed column-wise which includes the user’s login, full anime, terminal type, idle, login time, office, and office location. 

Moreover, it also displays the “project”, “plan”, and “pgp-key” associated with the specified users. Furthermore, it also supports a group of options that change its output as per user’s requirement. This post has illustrated the finger command deeply in Linux.