Beginners Guide for Finger Command in Linux

Linux TLDR
Last Updated:
Reading time: 3 minutes

The finger is an external command-line tool that can be used to list all the logged-in users on a remote machine or server, like โ€œwโ€ or โ€œwhoโ€ commands.

This tool is also referred to as a โ€œuser information lookup programโ€, as it provides you with user related information like their home directory, default shell, when they logged-in, etc.

In this article, you will learn how to list all users and view their information using the finger command (with practical examples).

๐Ÿ“
This command previously had security flaws and was heavily exploited by an attacker in 2021 for phishing campaigns.

Tutorial Details

DescriptionUser Information Lookup
Difficulty LevelLow
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Fedora, etc.
Prerequisitesfinger
Internet RequiredYes

How to Install Finger in Linux

As Iโ€™ve already said, this is an external command that doesnโ€™t come with Linux, but itโ€™s easy to install with any of the following commands:

๐Ÿ“
The Arch system did not work well for me; if you have any alternatives (except โ€œpinkyโ€), please let me know in the comments section.
$ sudo apt install finger                                                                                  #On Debian and Ubuntu
$ sudo dnf install finger                                                                                  #On Red Hat and Fedora

After the installation is complete, you can start using it, but first read our complete article.

Usage of the Finger Command

The finger command takes two arguments: one is the option, and the other is the username.

$ finger [OPTION] [USERNAME]

The following is an example of this command when executed without any options:

$ finger

Output:

output of a finger command

The following is a breakdown of the above output.

  • Login: Userโ€™s account name.
  • Name: The full name of the given user.
  • Tty: How users connected to the system.
  • Idle: User inactivity (or idle time).
  • Login Time: When the users log-in to the system.
  • Office: The userโ€™s hostname or IP address.
  • Office Phone: Show the user phone number form โ€œ/etc/passwdโ€ file, if itโ€™s not blank.

Once you are familiar with this output, you can move on to the next section.

Get Information About a Particular User Using the Finger Command

If you give this command any of the users listed above as an argument, it will give you more information about that specific user.

๐Ÿ“
You can specify multiple users names by using the space as a separator.
$ finger david

Output:

Checking single user information using the finger command

Letโ€™s break down this output to learn more.

  • Login: User account name.
  • Name: The full name associated with the given username.
  • Directory: User home directory.
  • Shell: User default login shell.
  • Then comes a brief description of how the user logged in to the target machine (via which method) using their hostname or IP address.
  • Mail: Display the mails in the user inbox.
  • Plan: Display the content of the โ€œ~/.planโ€ or โ€œ~/.projectโ€ file in the userโ€™s home directory.

Now letโ€™s check out a few options offered by this command.

Finger Command Options

The finger command offers various options that can change the output based on the specified option, starting with

Display the Output in Columns for a Particular User

The โ€œ-sโ€ flag will show the particular user information column-wise, identical to the standard finger output when executed without options or usernames.

$ finger -s david

Output:

Showing the particular user information in columns

As you can see, the particular userโ€™s login name, real name, terminal name, and other information are arranged in the single column.

Display the Output in Long Listing for All Users

The default setting for finger command output without any option or argument is to show all the logged-in users information in a single column.

However, you can output all the logged-in users information in a long listing (producing multi-line output) that includes all the users information like home directory, home phone number, login shell, mail status, etc. using the โ€œ-lโ€ flag.

$ finger -l

Output:

Showing all the users information in a long listing

Hide the Plain Field from the Output

The โ€œ-pโ€ flag will show the output without the plan field.

$ finger -p david

Output:

Hiding the plan field for particular user

You can use this option in combination with the โ€œ-lโ€ flag to list all the user information without a plan field.

$ finger -lp

Output:

Hiding the plan field for all users

Match Only with Login Names Against Userโ€™s Names

When you execute this command with or without any of the flags mentioned above, it will list the users based on their name (real name) and login name (username).

And this way of listing the user might give you multiple results in the output, especially when the name and login name match.

$ finger david

Output:

Multiple users share a common name in the system

As you can see in the above picture, we have one user with the login name โ€œdavidโ€ and another user with the real name โ€œdavidโ€œ, Listing the users based on name and login name leads to these two results.

To avoid this, you can use the โ€œ-mโ€ flag to list the user based on their login name.

$ finger -m david

Output:

Listing the user based on their login name

How to Uninstall/Remove Finger in Linux

In case you didnโ€™t like this program and want to remove it from your system, then execute any one of the following commands based on your system.

$ sudo apt remove finger                                                                                 #On Debian and Ubuntu
$ sudo dnf remove finger                                                                                 #On Red Hat and Fedora

So, that was the last example.

Although, this is an amazing tool, to be honest I still use the w command to find all the logged-in users in the target system and read the โ€œ/etc/passwdโ€ file to view all the user account information in the target system.

Still, I would love to hear your opinion regarding these tools.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.

4 thoughts on โ€œBeginners Guide for Finger Command in Linuxโ€

  1. Iโ€™m surprised to read a tutorial about โ€œfingerโ€ in 2023 without a single word about the security issues involved.

    Reply
    • Hi Christian,

      You mentioned a good point, and I am aware of the finger command security holes in the past and that they were heavily pursued in 2021 for phishing campaigns. However, I was unable to verify whether the security issues still exist or not.

      If you have any information, then do reply to this comment with that information.

      Reply
  2. Well, opening up a port to remotely list users with additional information is always a nice way for an attacker to find targets. This may be not a big issue for a hobby system at home, but already for a private laptop in another network.
    Curiously, the first paragraph of the article describes this as a way to query users remotely, but the tutorial only show the local use case.

    Reply