title | date | icon | background | tags | categories | intro | ||||
---|---|---|---|---|---|---|---|---|---|---|
Lsof |
2021-02-05 08:12:47 -0800 |
icon-style |
bg-blue-400 |
|
|
This quick reference cheat sheet provides various for using lsof command.
|
lsof meaning L
iS
t O
pen F
iles is used to find out which files are open by which process
$ lsof
$ sudo lsof -u root
$ lsof -i :8080
$ lsof -i :80 -i :22
$ lsof -i TCP:22
$ lsof -i TCP:1-1024
$ lsof -i UDP
$ lsof -i @192.168.1.5
$ lsof -c mysql
$ lsof -c java
$ lsof -c ssh
$ lsof -c nginx
$ lsof -c ssh -c httpd
$ lsof -u www-data
$ lsof -u www-data -u ubuntu
$ lsof -i -u ^root # Except certain user
$ lsof -i 4 # IPv4 only
$ lsof -i 6 # IPv6 only
$ lsof -p 1753
$ lsof -p ^3 # Except certain pids
$ lsof /var/log/messages
$ lsof /etc/passwd
$ lsof +D /var/log # Within a directory
$ kill -9 `lsof -t -u apache`
$ kill -9 $(lsof -t -i :8080)