Want to find out all the users who logged into your system? Don’t raise your finger; raise your pinky instead.
Confused about what I am talking about? Let me explain what I mean. In Linux, there are numerous tools to show you all the logged-in users on the target machine, including built-in and external tools.
The finger is one of the external tools used to list all of the logged-in users in the target machine, and fetching user related information like home directories, default shells, home phone numbers, etc. is part of this tool.
Unfortunately, this tool is not shipped by default in many Linux distributions (although it is available in many Linux repositories), but you don’t have to be downhearted as you can utilize its alternative pinky.
|Pinky: An Alternative to the Finger
|Root or Sudo Privileges
|Ubuntu, Manjaro, Fedora, etc.
What is “Pinky” in Linux?
The pinky is a lightweight and modern version of the finger tool that ships out of the box for most Linux distributions like Ubuntu, Fedora, and Manjaro, unlike the finger.
Yet, some Linux distributions may not include this tool, which you can install by following the next section.
How to Install Pinky in Linux
If, out of the blue, this command went missing or was not installed in your system, then execute any one of the following commands to install it on your Linux system.
$ sudo apt install pinky #On Debian and Ubuntu
$ sudo dnf install pinky #On Red Hat and Fedora
$ sudo pacman -S pinky #On Arch and Manjaro
After the installation is complete, you can jump to the next section to learn more about this tool.
Usage of the Pinky Command
The pinky command takes two arguments (identically to finger), one for the option and the other for the username.
$ pinky [OPTION] [USERNAME]
When this command is run without any options or usernames, the following output will be shown:
As you can see from the above picture, three (“
david“, and “
jake“) users are connected to the target machine.
The following is an explanation of all the fields mentioned in the above output.
Login: The user’s account name.
Name: The full (or real) name of the corresponding user.
TTY: How users connected to the target machine, locally (
tty) or remotely (
Idle: Idle (or inactivity) of the user.
When: Date and time when the user logged-in to the system.
Where: The hostname or IP address of the user’s system.
If you have ever used the finger command, then you can easily figure out that both of these commands return the same output.
Reporting on a Single User
By default, the pinky reports all the user’s information that is logged in during that time frame; however, you can narrow down the output to a particular user by specifying their login name.
$ pinky david
Now, let’s keep this aside and jump to the next section to look at the various options offered by this command.
Pinky Command Options
The pinky command accepts various options based on which you can hide the header, full name, host name, idle time, etc. based on the specified option.
Do Not Print the Header in the Output
-f” flag can be specified with or without a username to hide the header from the output.
$ pinky -f
Display Specific User Information in Long Format
By default, the pinky command returns the single specified user output in a single column that can be changed to a long format.
In this format, some extra information related to the specified user will be included, like the user’s home directory and default login shell.
$ pinky -l david
Note that when you use the “
-l” flag for long format, you must specify at least one username.
Omit the User’s Home Directory and Shell in Long Format
-b” flag with the “
-l” flag will return the user’s information by excluding the user’s home directory and shell from the output.
$ pinky -lb david
Omit the Users Full Name in the Output
-w” flag can be specified with or without username to hide the full (or real) name of the users from the output.
$ pinky -w
Omit the Users Full Name and Remote Host in the Output
-i” can be specified with or without username to hide the user’s full (or real) name and remote host from the output.
$ pinky -i
Hide the Users Full Name, Remote Host, and Idle Time in the Output
-q” flag can be specified with or without username to remove the user’s full (or real) name, remote host, and idle time from the output.
$ pinky -q
How to Uninstall/Remove the Pinky from Linux
Execute any of the following commands to remove this program from your system:
$ sudo apt remove pinky #On Debian and Ubuntu
$ sudo dnf remove pinky #On Red Hat and Fedora
$ sudo pacman -R pinky #On Arch and Manjaro
That was the last example of this command.
If you are familiar with the finger command, then you can easily spot that both commands are too similar in terms of naming the options or output.
However, if you have any interesting or advanced tools for sysadmins, then let us know in the comment section.
Till then, peace!