Linux finger Command Tutorial for Beginners (5 Examples)

linux finger command tutorial for beginners 5

If you are a Linux system admin, or your work involves managing users, there are many tools that you should be aware of. Once such command line utility is finger, basics of which we’ll be discussing here in this tutorial. But before we start with that, it’s worth mentioning that all examples here have been tested on an Ubuntu 18.04 LTS machine.

Linux finger command

The finger command in Linux is basically a user information lookup program. Following is its syntax:

finger [-lmsp] [user ...] [[email protected] ...]

And here’s how the tool’s man page explains it:

The finger displays information about the system users.

Following are some Q&A styled examples that should give you a better idea on how the finger command works.

Q1. How to use finger command?

Basic usage is simple, just execute ‘finger’ with name of a user as input. Here’s an example:

finger himanshu

And here’s the output the above command produced on my system:

Login: himanshu                   Name: Himanshu
Directory: /home/himanshu               Shell: /bin/bash
On since Sat Nov 24 10:16 (IST) on :0 from :0 (messages off)
No mail.
No Plan.

Q2. How to make finger display output columns wise?

This can be done using the -s command line option. Here’s an example:

finger -s himanshu

And here’s the output produced:

Login     Name       Tty      Idle  Login Time   Office     Office Phone
himanshu  Himanshu  *:0             Nov 24 10:16 (:0)

Q3. How to make finger restrict some info in output?

There’s a command line option -p that forces finger to not display the contents of the “.plan”, “.project” and “.pgpkey” files. Here’s an example:

finger -p himanshu

And here’s the output:

Login: himanshu                   Name: Himanshu
Directory: /home/himanshu               Shell: /bin/bash
On since Sat Nov 24 10:16 (IST) on :0 from :0 (messages off)
No mail.

So you can see info related to ‘plan’ was not displayed in the output.

Q4. How to prevent matching of user real names?

By default, the input user name you provide is matched for user login names as well as real names. But if you want, you can disable the latter matching using the -m command line option.

finger -m himanshu

Q5. What are some other points worth knowing about finger?

Here’s a relevant excerpt from the tool’s man page:

If no options are specified, finger defaults to the -l style output if operands are provided, 
otherwise to the -s style.  Note that some fields may be missing, in either format, if information
is not available for them.

If no arguments are specified, finger will print an entry for each user currently logged into the
system.

Finger may be used to look up users on a remote machine.  The format is to specify a user as
[email protected]”, or “@host”, where the default output format for the former is the -l style, and the
default output format for the latter is the -s style.  The -l option is the only option that may
be passed to a remote machine.

If standard output is a socket, finger will emit a carriage return (^M) before every linefeed (^J).
This is for processing remote finger requests when invoked by fingerd(8).

Conclusion

Depending on the kind of work you do on your Linux box, the finger command may be of great help to you. Head to the tool’s man page to learn more about it. And as for alternatives, you can check out the Pinky command.

نوشته های مشابه