Sunday, October 7, 2018

How to find which applications are connecting to internet or local network on your Linux machine?

It has been a very long time since I posted something on my blog! However, I just thought I could come back with a small post! Imagine I want to find which I find out which processes on my machine is connected through TCP or UPD on my system. a simple way is to just run:

$lsof -i

 lsof actually only list the open files in the system. adding -i option will  option produces a listing of all network files. which is what we are interested. If they are multiple users and we want open files for a $USER we just add u option:

$lsof -u$USER (for example: ls -ufoo for user 'foo') 

If I want to see connections for example on a specific port  I do :

 $losf -i :port ---> example: lsof -i :80

No comments: