mirror of
https://github.com/Fechin/reference.git
synced 2026-11-25 07:04:42 +03:00
fix: trivial formatted posts
Every other file's format which was automatically converted correctly. Each has been manually checked and they should all be visually the same.
This commit is contained in:
97 files changed
+10250
-10850
No files matched your search
+14
-18
@@ -3,21 +3,21 @@ title: Lsof
|
||||
date: 2021-02-05 16:12:47
|
||||
background: bg-blue-400
|
||||
tags:
|
||||
- port
|
||||
- processes
|
||||
- utility
|
||||
- port
|
||||
- processes
|
||||
- utility
|
||||
categories:
|
||||
- Linux Command
|
||||
- Linux Command
|
||||
intro: |
|
||||
This quick reference cheat sheet provides various for using lsof command.
|
||||
This quick reference cheat sheet provides various for using lsof command.
|
||||
plugins:
|
||||
- copyCode
|
||||
- copyCode
|
||||
---
|
||||
|
||||
Getting Started
|
||||
--------------
|
||||
## Getting Started
|
||||
|
||||
### Introduction
|
||||
|
||||
**lsof** meaning `L`i`S`t `O`pen `F`iles is used to find out which files are open by which process
|
||||
|
||||
```shell script
|
||||
@@ -36,9 +36,8 @@ $ lsof -i UDP
|
||||
$ lsof -i @192.168.1.5
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Process-specific
|
||||
|
||||
```shell script
|
||||
$ lsof -c mysql
|
||||
$ lsof -c java
|
||||
@@ -47,7 +46,6 @@ $ lsof -c nginx
|
||||
$ lsof -c ssh -c httpd
|
||||
```
|
||||
|
||||
|
||||
### User-specific
|
||||
|
||||
```shell script
|
||||
@@ -56,38 +54,36 @@ $ lsof -u www-data -u ubuntu
|
||||
$ lsof -i -u ^root # Except certain user
|
||||
```
|
||||
|
||||
|
||||
### Network-specific
|
||||
|
||||
```shell script
|
||||
$ lsof -i 4 # IPv4 only
|
||||
$ lsof -i 6 # IPv6 only
|
||||
```
|
||||
|
||||
### PID-specific
|
||||
|
||||
```shell script
|
||||
$ lsof -p 1753
|
||||
$ lsof -p ^3 # Except certain pids
|
||||
```
|
||||
|
||||
### Filename-specific
|
||||
|
||||
```shell script
|
||||
$ lsof /var/log/messages
|
||||
$ lsof /etc/passwd
|
||||
```
|
||||
|
||||
|
||||
### Directory-specific
|
||||
|
||||
```shell script
|
||||
$ lsof +D /var/log # Within a directory
|
||||
```
|
||||
|
||||
|
||||
### Kill
|
||||
|
||||
```shell script
|
||||
$ kill -9 `lsof -t -u apache`
|
||||
$ kill -9 $(lsof -t -i :8080)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user