DEV Community

Weerasak Chongnguluam
Weerasak Chongnguluam

Posted on

3 1

หา process id ที่เปิด port อยู่ด้วย lsof -i

บางครั้งเรารันโปรแกรมที่เป็น background process ไว้แล้วมันเปิด port ที่เราต้องการใช้งานเอาไว้ด้วย ทำให้เราเอา port ไปให้ต่อไม่ได้ ต้องทำการปิดโปรแกรมนั้นโดยหา process id แล้วไป kill process นั้นก่อน

คำสั่งที่ช่วยหาว่า process id อะไรของโปรแกรมไหนใช้ port อยู่คือ lsof โดยใช้ร่วมกับ option -i เช่นต้องการหาว่าโปรแกรมไหนเปิด port 12345 อยู่ก็สั่งได้แบบนี้

lsof -i :12345
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay