Thursday, August 22, 2024

How see complete path of a process running on specific port in linux

To find the complete path of a process that is using a specific port in Linux, you can follow these steps:

Step 1: Find the PID of the Process

1. Using `lsof` Command**:

   - Open a terminal and run the following command (replace `PORT_NUMBER` with the actual port number):

     --------------------------------------------------------------------

     sudo lsof -i :PORT_NUMBER

     --------------------------------------------------------------------

   - This command will list all processes using the specified port, along with their PIDs.

2. Using `netstat` Command**:

   - Alternatively, you can use the `netstat` command:

     --------------------------------------------------------------------

     sudo netstat -tulpn | grep :PORT_NUMBER

     --------------------------------------------------------------------

   - This will show you the PID and the program name associated with the port.

Step 2: Get the Complete Path of the Process

Once you have the PID from the previous step, you can find the complete path of the process:

1. Using `ps` Command**:

   - Run the following command (replace `YOUR_PID` with the PID you obtained):

     --------------------------------------------------------------------

     ps -p YOUR_PID -o args=

     --------------------------------------------------------------------

   - This command will display the command line that started the process, including the complete path.

2. Using `/proc` Filesystem**:

   - You can also check the `/proc` filesystem for more details:

     --------------------------------------------------------------------

     ls -l /proc/YOUR_PID/exe

     --------------------------------------------------------------------

   - This will show you a symbolic link to the executable of the process, revealing its complete path.


No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

Different #memories in #free #command in #linux

The   free   command in Linux is a powerful tool for monitoring memory usage on your system. It provides information about various types of ...