A script for Linux which displays the local users who are using a specified application or service.

 Hello guy’s, Welcome to another article, we are all interested to know other person details or any information but we don’t know how to get or see. In this article im going to show you how to see local users using services or applications

Requirement’s

How to install and use Whoisusing tool

Step 1: clone the package

First you download whoisusing package in your linux so type this below command

git clone https://github.com/ronrihoo/whoisusing.git

Step 2: change the directory

Now change the directory of whoisusing so type this below command in your linux terminal

cd whoisusing

Step 3: Change the permission

Now give permission to read write and execute of all python files so type this below command in your linux terminal.

chmod +x *.py

How to use Whoisusing tool

whoisusing <name> <option>

Example:$ whoisusing mysql mysql 


The output is the name of the user.

Options:

-a : Return the actual filename associated with found processes$ whoisusing cups -a root cupsd cups-browsed lp dbus

The actual filenames retrieved for each user are separated from each other by a space.

-s : Returns only the results that have matching filenames

Notice the actual name above for user lp is too different from the searched name cups. In order to prevent this, the strict option flag, -s, will ensure that the associated filenames are a close match to the searched name.whoisusing cups -s root

Additionally, one may combine options for more detailed results, like so:

$ whoisusing cups -sa root cupsd -p : Return users with their associated PIDs$ whoisusing mysql -p mysql 1412

Similar to ps aux | grep mysql | awk ‘{ print $1, $2 }’ with the difference being that all of the associated PIDs of each unique user are listed on the same line, like so:

$ whoisusing mysql -p mysql 1412 1413 -where the latter would display:$ ps aux | grep mysql | awk ‘{ print $1, $2 }’ mysql 1412 mysql 1413

-d : Return the directories associated with the user who’s using the specified process

$ whoisusing cups -d root /usr/sbin/cupsd /usr/sbin/cups-browsed lp /usr/lib/cups/notifier/dbus

This can be combined with other options.

$ whoisusing cups -apd root cupsd 3703 cups-browsed 3704 /usr/sbin/cupsd /usr/sbin/cups-browsed lp dbus 3712 /usr/lib/cups/notifier/dbus

-l : Return the lines that were used to determine who the users are

$ whoisusing mysql -l mysql 1412 0 1.5 1253291 156937 ? Ssl 00:20 0:01 /usr/sbin/mysqld mysql

The line returned is exactly similar to the output of ps aux | grep mysql. In case of multiple results, first all of the lines will be printed in the same respective order as the user names which follow.

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *