How to use the command 'finger' (with examples)

How to use the command 'finger' (with examples)

The ‘finger’ command is a user information lookup program that provides details about currently logged in users. It can display information about a specific user, such as their login name, real name, terminal name, home directory, home phone number, login shell, and mail status.

Use case 1: Display information about currently logged in users

Code:

finger

Motivation: This use case allows you to see a list of all the users who are currently logged in to the system. It can be helpful for administrators who want to check the system’s usage or for users who want to know if their colleagues or friends are currently online.

Explanation: By running the ‘finger’ command without any arguments, you are requesting information about all currently logged in users. It will display details such as their login name, terminal name, idle time (how long they have been inactive), login time, and more.

Example output:

Login    Name                 TTY Idle    When             Where
user1    John Smith           pts/0          24 Dec 15:30   192.168.1.100
user2    Jane Doe             pts/1          1h              192.168.1.101
user3    Robert Johnson       pts/2          2d              192.168.1.102

Use case 2: Display information about a specific user

Code:

finger username

Motivation: This use case allows you to retrieve detailed information about a specific user. It can be useful when you want to quickly find out information about a colleague, friend, or yourself.

Explanation: By providing the username as an argument to the ‘finger’ command, you will get information specifically about that user. It will display details such as their login name, real name, terminal name, idle time, login time, and more.

Example output:

Login    Name                 TTY Idle    When             Where
user1    John Smith           pts/0          24 Dec 15:30   192.168.1.100

Use case 3: Display the user’s login name, real name, terminal name, and other information

Code:

finger -s

Motivation: This use case allows you to get a concise overview of a user’s information, including their login name, real name, and terminal name. It can be useful when you only need basic details about a user.

Explanation: By using the ‘-s’ option with the ‘finger’ command, you will receive a summary of a user’s information. It will display their login name, real name, terminal name, idle time, and when they were last logged in.

Example output:

Login    Name                 TTY Idle    When
user1    John Smith           pts/0          24 Dec 15:30

Use case 4: Produce multiline output format displaying the same information as ‘-s’ as well as user’s home directory, home phone number, login shell, mail status, etc.

Code:

finger -l

Motivation: This use case allows you to retrieve more detailed information about a user, including their home directory, home phone number, login shell, and mail status. It can be useful when you need a comprehensive profile of a user.

Explanation: By using the ‘-l’ option with the ‘finger’ command, you will receive a multiline output format with additional information about a user. It will display their login name, real name, terminal name, idle time, home directory, home phone number, login shell, and mail status.

Example output:

Login    Name                 TTY Idle    When             Home Directory    Home Phone     Login Shell     Mail
user1    John Smith           pts/0          24 Dec 15:30   /home/user1      1234567890     /bin/bash       New mail received

Use case 5: Prevent matching against user’s names and only use login names

Code:

finger -m

Motivation: This use case allows you to search for users based on their login names instead of their real names. It can be useful when you are searching for a specific user and want to avoid any potential matches based on similar names.

Explanation: By using the ‘-m’ option with the ‘finger’ command, you can prevent matching against user’s names and only use login names. It will only return users with the exact login name provided as an argument.

Example output:

Login    Name                 TTY Idle    When             Where
user1    John Smith           pts/0          24 Dec 15:30   192.168.1.100

Conclusion:

The ‘finger’ command is a versatile tool for retrieving user information on a Unix-like system. Whether you need a quick overview of currently logged in users or detailed information about a specific user, the ‘finger’ command provides a variety of options to fulfill your needs.

Related Posts

How to use the command graphml2gv (with examples)

How to use the command graphml2gv (with examples)

The graphml2gv command is part of the Graphviz package and is used to convert a graph from graphml format to gv format.

Read More
Using the `arch` Command (with examples)

Using the `arch` Command (with examples)

1: Display the system’s architecture arch Motivation: This use case is helpful when you want to quickly determine the architecture of your system.

Read More
Using the lsof command (with examples)

Using the lsof command (with examples)

The lsof command is a powerful tool for listing open files and the processes that have opened them.

Read More