Linux /
Lsoflsof: lists open filesKaynak: http://dmiessler.com/study/lsof/Show all connections with -ilsof -i Show only TCP (works the same for UDP)lsof -iTCP -i :port shows all networking related to a given portlsof -i :22 To show connections to a specific host, use @hostlsof [email protected] Show connections based on the host and the port using @host:portlsof [email protected]:22 Grepping for "LISTEN" shows what ports your system is waiting for connections onlsof -i| grep LISTEN Grepping for "ESTABLISHED" shows current active connectionslsof -i| grep ESTABLISHED Show what a given user has open using -ulsof -u daniel See what files and network connections a command is using with -clsof -c syslog-ng Pointing to a file shows what's interacting with that filelsof /var/log/messages The -p switch lets you see what a given process ID has open, which is good for learning more about unknown processeslsof -p 10075 The -t option returns just a PIDlsof -t -c Mail Using-a allows you to combine search terms, so the query below says, "show me everything running as daniel connected to 1.1.1.1"lsof -a -u daniel -i @1.1.1.1 Using the -t and -c options together you can HUP processeskill -HUP `lsof -t -c sshd` You can also use the -t with -u to kill everything a user has openkill -9 `lsof -t -u daniel` lsof +L1 shows you all open files that have a link count less than 1, often indicative of a cracker trying to hide somethinglsof +L1 |