$ netstat -tulpn | (read -r h1; read -r h2; echo "$h1"; echo "$h2"; sort -k1,1 -k4,4) | grep "java"
Method 1: Using the /proc File System (Fastest)
In Linux, every running process has a directory under /proc named after its PID. You can look at the symbolic link exe to see exactly what binary is running, or check the working directory.
Run this command to find the executable path:
$ ls -l /proc/$(lsof -t -i:8091)/exe
Run this command to find the working directory from which it was started:
$ ls -l /proc/$(lsof -t -i:8091)/cwd
----- ----- ----- ----- -----
Method 2: Using the ps Command (Most Detailed)
Since this is a Java application, ls -l /proc/$(lsof -t -i:8091)/exe will likely just point to your system's Java installation path (e.g., /usr/bin/java).
To see the actual .jar file or class path that Java is executing, you need to see the full command-line arguments. Run:
$ ps -ef | grep $(lsof -t -i:8091)
Or for a cleaner, dedicated output (I highly recommended use this method.) :
$ ps -p $(lsof -t -i:8091) -o cmd
----- ----- ----- ----- -----
The Quick Alternative
If you want an even easier way that directly outputs the exact command line and file path for that specific port without worrying about ps formatting flags, you can read it straight from the system's process environment:
$ tr '\0' ' ' < /proc/$(lsof -t -i:8091)/cmdline

Comments
Post a Comment