Using the Pinky Command (with examples)
The pinky
command is used to print user information using the finger
protocol. It provides detailed information about a user, such as their login name, real name, terminal, idle time, login time, and more. This article will explore the different use cases of the pinky
command and provide code examples for each use case.
Use Case 1: Display details about the current user
pinky
Motivation: When you want to quickly access information about the currently logged-in user, including their login name, real name, terminal, idle time, and login time, you can use the pinky
command without any arguments.
Explanation: Running pinky
without any arguments displays details about the current user. The command retrieves the user information using the finger
protocol.
Example Output:
Login: user123 Name: John Doe
Directory: /home/user123 Shell: /bin/bash
Never logged in.
No mail.
No Plan.
Use Case 2: Display details for a specific user
pinky user
Motivation: If you want to retrieve information about a specific user, you can use the pinky
command followed by the username as an argument. This can be useful for administrators or when troubleshooting user-related issues.
Explanation: By specifying a username as an argument after the pinky
command, you can retrieve details about that specific user’s account.
Example Output:
Login: user123 Name: John Doe
Directory: /home/user123 Shell: /bin/bash
Never logged in.
No mail.
No Plan.
Use Case 3: Display details in the long format
pinky user -l
Motivation: When you need more detailed information about a user, including their email address, office location, phone number, and more, you can use the pinky
command with the -l
option to display the user details in the long format.
Explanation: The -l
option is used to display the user information in the long format, providing additional details such as email address, office location, office phone, home phone, and other fields if available.
Example Output:
Login: user123 Name: John Doe
Directory: /home/user123 Shell: /bin/bash
Never logged in.
No mail.
No Plan.
Use Case 4: Omit the user’s home directory and shell in long format
pinky user -lb
Motivation: In some cases, you may want to exclude the user’s home directory and shell from the long format output. This can be useful if you only need specific information about the user and want to have a more concise output.
Explanation: The -b
option is used to omit the user’s home directory and shell from the long format output. This can make the output cleaner and highlight other essential information.
Example Output:
Login: user123
Never logged in.
No mail.
No Plan.
Use Case 5: Omit the user’s project file in long format
pinky user -lh
Motivation: When using the long format output, you may want to exclude the user’s project file information. This can be helpful if you don’t require project-related details or if you prefer a cleaner output.
Explanation: The -h
option is used to omit the user’s project file information from the long format output. This can simplify the output, especially if project-related information is not relevant to your use case.
Example Output:
Login: user123 Name: John Doe
Directory: /home/user123 Shell: /bin/bash
Never logged in.
No mail.
No Plan.
Use Case 6: Omit the column headings in short format
pinky user -f
Motivation: If you prefer a more compact and concise output, you can use the -f
option to omit the column headings. This can be useful when parsing the output programmatically or when you want to save space in your terminal.
Explanation: The -f
option is used to omit the column headings in the short format output. This makes the output more concise and is particularly useful when you want to process the output programmatically.
Example Output:
user123 John Doe Never logged in.