Introduction
In this lab, we will explore the Linux finger command, which provides information about system users. The finger command is a useful tool for system administrators and users to quickly access user-related details. We will learn how to display user information, including login name, real name, terminal, idle time, login time, and other details. Additionally, we will cover how to customize the finger command output. This lab is focused on user and permission management skills.
The finger command is installed by default on most Linux distributions, but it may need to be installed on some systems. If the finger command is not installed, you can install it using your system's package manager. The finger command is a standard Linux tool, but it is worth noting that it may be considered outdated or deprecated in some modern Linux distributions, and alternative tools may be preferred.
Introduction to the finger Command
In this step, we will explore the Linux finger command, which provides information about system users. The finger command is a useful tool for system administrators and users to quickly access user-related details.
To begin, let's start by checking if the finger command is installed on our Ubuntu 22.04 Docker container:
sudo apt-get update
sudo apt-get install -y finger
Example output:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
finger
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 45.8 kB of archives.
After this operation, 119 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 finger amd64 0.17-14build1 [45.8 kB]
Fetched 45.8 kB in 0s (0 B/s)
Selecting previously unselected package finger.
(Reading database ... 14375 files and directories currently installed.)
Preparing to unpack .../finger_0.17-14build1_amd64.deb ...
Unpacking finger (0.17-14build1) ...
Setting up finger (0.17-14build1) ...
The finger command is now installed and ready to use. Let's move on to the next step to learn how to display user information with the finger command.
Displaying User Information with the finger Command
In this step, we will learn how to use the finger command to display information about system users.
To start, let's check the current users logged into the system:
finger
Example output:
Login Name Tty Idle Login Time Office Office Phone
labex Labex User pts/0 0 Apr 11 12:34 (192.168.1.100)
The finger command without any arguments will display information about all users currently logged into the system. This includes the user's login name, real name, terminal, idle time, login time, and other details.
We can also use the finger command to display information about a specific user. For example, to get information about the labex user, we can run:
finger labex
Example output:
Login: labex Name: Labex User
Directory: /home/labex Shell: /bin/bash
On since Apr 11 12:34 (UTC) on pts/0 from 192.168.1.100
No mail.
No plan.
This provides more detailed information about the labex user, including their home directory, shell, and login session details.
The finger command can be a useful tool for system administrators and users to quickly access user-related information on a Linux system.
Customizing the finger Command Output
In this final step, we will learn how to customize the output of the finger command to display only the information we need.
By default, the finger command displays a lot of information about each user, which may not always be necessary. We can customize the output by using the -l (long) or -p (personal) options.
To display a more concise user information, let's use the -l option:
finger -l labex
Example output:
Login: labex Name: Labex User
Directory: /home/labex Shell: /bin/bash
On since Apr 11 12:34 (UTC) on pts/0 from 192.168.1.100
No mail.
No plan.
The -l option displays the user's login name, real name, home directory, shell, login time, and terminal information.
If we only want to see the user's login name, real name, and login time, we can use the -p option:
finger -p labex
Example output:
labex Labex User Apr 11 12:34
The -p option displays a more compact user information format, including just the login name, real name, and login time.
By customizing the finger command output, you can quickly access the user information that is most relevant to your needs.
Summary
In this lab, we explored the Linux finger command, which provides information about system users. We first learned how to install the finger command on our Ubuntu 22.04 Docker container. Then, we discovered how to use the finger command to display information about users currently logged into the system, including their login name, real name, terminal, idle time, and login time. Additionally, we learned how to customize the finger command output to retrieve specific user information, such as the user's full name, email address, and other details.



