-
-
Save tianchaijz/7b0cdc612b24116ca479e99d2b6fe680 to your computer and use it in GitHub Desktop.
Shell command lsof : see open files and ports; Selection is OR by default, use -a for AND; Tested on OSX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#list all ports for tcp | |
sudo lsof -itcp | |
#find all things listening on ports | |
lsof -Pnl +M -i4 | grep LISTEN | |
#all ports for tcp, dont resolve port name from numbers | |
sudo lsof -itcp -P | |
#open files and ports of process #$PID | |
sudo lsof -p $PID | |
#only ports of tcp for process #$PID, dont resolve port name, dont resolve ip name | |
sudo lsof -a -p $PID -P -n -itcp | |
#only ports of tcp for process #$PID, dont resolve port name, dont resolve ip name, refresh every 5 seconds | |
sudo lsof -a -p $PID -P -n -itcp -r 5 | |
#search by file (can be slow) | |
sudo lsof /complete/path/to/file | |
#plenty more options and usage patterns |
akrisiun
commented
Nov 10, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment