What process is listening on a certain port on Solaris?

后端 未结 11 1220
情话喂你
情话喂你 2020-12-13 02:24

So I log into a Solaris box, try to start Apache, and find that there is already a process listening on port 80, and it\'s not Apache. Our boxes don\'t have lsof installed,

11条回答
  •  我在风中等你
    2020-12-13 03:12

    Here's a one-liner:

    ps -ef| awk '{print $2}'| xargs -I '{}' sh -c 'echo examining process {}; pfiles {}| grep 80'
    

    'echo examining process PID' will be printed before each search, so once you see an output referencing port 80, you'll know which process is holding the handle.

    Alternatively use:

    ps -ef| grep $USER|awk '{print $2}'| xargs -I '{}' sh -c 'echo examining process {}; pfiles {}| grep 80'
    

    Since 'pfiles' might not like that you're trying to access other user's processes, unless you're root of course.

提交回复
热议问题