http://blog.longwin.com.tw/2012/05/lsof ... 7s+Blog%29
使用 lsof (list open files) 來看某個 Port 的 Connection 狀態, 並且查看此 Port 是被哪支程式佔住了.
註1: netstat 也可以作類似的事情, 但是 lsof 更簡單易懂些.
註2: 主要用此可以查看, 是否有哪些連線是你意想不到的. (會不會是被種了木馬等等的)
使用 lsof 監看本機對外連線指令參數
lsof 命令參數如下述:
lsof -i :80 # 80 是 Port number
lsof | grep TCP # 看現在有開哪些 TCP port
lsof -Pni |grep ":80" # 看詳細 80Port 的連線狀況
lsof -i -P | grep -i "LISTEN" # 看現在有哪些 Port 正在監聽服務
lsof 監看 Port 的操作範例
lsof -i :80 # 本機 80 Port 對外連線的狀況
dropbox 2070 user 21u IPv4 77760 0t0 TCP x220i.local:52980->xxx.sjc.dropbox.com:http (ESTABLISHED)
ubuntu-ge 2252 user 7u IPv4 76945 0t0 TCP x220i.local:49170->xxx.canonical.com:http (CLOSE_WAIT)
unity-sco 2528 user 12u IPv4 57507 0t0 TCP x220i.local:46337->xxx.canonical.com:http (CLOSE_WAIT)
unity-sco 2528 user 14u IPv4 57508 0t0 TCP x220i.local:46338->xxx.canonical.com:http (CLOSE_WAIT)
firefox 5618 user 60u IPv4 97736 0t0 TCP x220i.local:46284->xxx.facebook.com:http (ESTABLISHED)
firefox 5618 user 120u IPv4 92880 0t0 TCP x220i.local:51870->xxx.tfbnw.net:http (ESTABLISHED)
lsof -i :22 # 本機 22 Port 對外的連線狀況
ssh 3175 user 3u IPv4 12676 0t0 TCP localhost:53854->hosted.by.obj.localhost:ssh (ESTABLISHED)
ssh 3227 user 3u IPv4 12262 0t0 TCP localhost:51271->hosted.by.obj.localhost:ssh (ESTABLISHED)
ssh 3331 user 3u IPv4 12815 0t0 TCP localhost:37037->obj-localhost:ssh (ESTABLISHED)
使用 lsof 監看本機 某個Port 的 對外連線狀況
前往
- Software
- ↳ CodeCharge Studio
- ↳ CodeCharge
- ↳ DemoCharge
- ↳ SuperPDF
- ↳ 551einv
- ↳ E3進銷存
- 程式語言
- ↳ PHP
- ↳ CodeLobster PHP Edition
- ↳ Yii
- ↳ CodeIgniter
- ↳ Phalcon
- ↳ Symfony
- ↳ FuelPHP
- ↳ Zend Framework 2
- ↳ laravel
- ↳ WordPress
- ↳ ASP.NET/C#
- ↳ ASP/VBScript
- ↳ JSP
- ↳ Java Servlets
- ↳ ColdFusion
- ↳ Perl
- ↳ Java Script
- ↳ jQuery
- ↳ HTML + CSS
- ↳ jQuery
- ↳ nodejs
- ↳ VB6
- ↳ Git
- ↳ App Inventor 2
- ↳ bash
- ↳ C++/ VC/ OpenCV
- ↳ OpenCV
- ↳ go
- ↳ cordova
- ↳ python
- ↳ Xamarin
- ↳ Assembly
- 資料庫
- ↳ MySQL
- ↳ PostgreSQL
- ↳ ORACLE
- ↳ Access
- ↳ SQL Server
- ↳ SQLite
- ↳ MariaDB
- ↳ Mongodb
- 作業系統
- ↳ Linux
- ↳ Ubuntu
- ↳ CentOS
- ↳ Mint
- ↳ Mandriva
- ↳ Debian
- ↳ Red Hat Enterprise Linux
- ↳ Oracle Linux
- ↳ Fedora
- ↳ Kali Linux
- ↳ OpenSUSE
- ↳ Elementary OS
- ↳ Microsoft
- ↳ Server 2008 R2
- ↳ Server 2012 R2
- ↳ Server 2012
- ↳ 8
- ↳ 10
- ↳ System Center 2016
- ↳ NOVELL
- ↳ FreeBSD
- ↳ VMware
- ↳ VirtualBox
- ↳ Mac OS X
- ↳ Solaris
- ↳ iOS
- ↳ Android
- ↳ Cloud
- ↳ OpenStack
- ↳ Docker
- ↳ Proxmox VE
- ↳ CloudReady
- ↳ chrome
- 網頁伺服器
- ↳ apache
- ↳ tomcat
- ↳ nginx
- ↳ IIS
- ↳ JBoss
- ↳ weblogic
- ↳ WebHosting
- 硬體
- ↳ 硬體及週邊
- ↳ RouterOS
- ↳ LEGO NXT
- ↳ Arduino
- ↳ MSP430
- ↳ Raspberry Pi
- ↳ OpenERP
- ↳ Storage
- ↳ Server
- ↳ Brocade
- ↳ MODELS
- ↳ FortiGate
- 軟體
- ↳ sublime
- ↳ LibreNMS