Finding Process ID (PID) using a port number in Solaris is not as easy as Linux.
If you are working on the setup of a new service and would like to allocate some port, you got to check if some other service uses that port.
You can find out which process is using the particular port in Solaris by below tiny shell scripts.
Following scripts will prompt you to enter the port number, and it will use
pfiles command internally to give you the
- Create a file with the following
#!/bin/ksh line='---------------------------------------------' pids=$(/usr/bin/ps -ef -o pid=) if [ $# -eq 0 ]; then read ans?"Enter Port Number To Know The pid: " else ans=$1 fi for f in $pids do /usr/proc/bin/pfiles $f 2>/dev/null | /usr/xpg4/bin/grep -q "port: $ans" if [ $? -eq 0 ]; then echo $line echo "Port: $ans is used by PID:c" pargs -l $f fi done
- Save and change the permission of the file to be executable
chmod 754 $filename
- Execute the file
Easy. Isn’t it?
Interested in learning Linux administration? Check out these resources.
More great readings on Sysadmin
A Brief Guide About Windows Management Instrumentation (WMI)Satish Shethi on June 28, 2022
10 Ways to Fix Errors to Seamlessly Play Steam Games on PCAnkush Das on June 23, 2022
Try These 7 Automatic Network Discovery Tools for Small to Medium BusinessesDurga Prasad Acharya on June 22, 2022
TCP vs. UDP: An Introduction GuideAmos Kingatua on June 20, 2022
SQL Server Management Studio (SSMS): Everything to Know in 2022Satish Shethi on June 16, 2022
Looking For Traceroute on RHEL 8? Try TracepathAbhishek Nair on June 14, 2022
Join Geekflare Newsletter
Every week we share trending articles and tools in our newsletter. More than 10,000 people enjoy reading, and you will love it too.