mirror of
https://github.com/Fechin/reference.git
synced 2026-11-20 21:23:11 +03:00
Every other file's format which was automatically converted correctly. Each has been manually checked and they should all be visually the same.
1.3 KiB
1.3 KiB
title, date, background, tags, categories, intro, plugins
| title | date | background | tags | categories | intro | plugins | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Lsof | 2021-02-05 16:12:47 | bg-blue-400 |
|
|
This quick reference cheat sheet provides various for using lsof command. |
|
Getting Started
Introduction
lsof meaning LiSt Open Files is used to find out which files are open by which process
$ lsof
$ sudo lsof -u root
Port-specific
$ 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
Process-specific
$ lsof -c mysql
$ lsof -c java
$ lsof -c ssh
$ lsof -c nginx
$ lsof -c ssh -c httpd
User-specific
$ lsof -u www-data
$ lsof -u www-data -u ubuntu
$ lsof -i -u ^root # Except certain user
Network-specific
$ lsof -i 4 # IPv4 only
$ lsof -i 6 # IPv6 only
PID-specific
$ lsof -p 1753
$ lsof -p ^3 # Except certain pids
Filename-specific
$ lsof /var/log/messages
$ lsof /etc/passwd
Directory-specific
$ lsof +D /var/log # Within a directory
Kill
$ kill -9 `lsof -t -u apache`
$ kill -9 $(lsof -t -i :8080)