2022-04-23 13:26:53 +01:00
|
|
|
---
|
|
|
|
tags:
|
|
|
|
- shell
|
2024-06-16 18:15:03 +01:00
|
|
|
- procedural
|
2022-04-23 13:26:53 +01:00
|
|
|
---
|
|
|
|
|
2024-10-18 20:00:02 +01:00
|
|
|
# Killing processes
|
|
|
|
|
2022-04-23 13:26:53 +01:00
|
|
|
## Kill a process running on a port
|
|
|
|
|
|
|
|
For example a local server.
|
|
|
|
|
2022-09-06 15:44:40 +01:00
|
|
|
```bash
|
2022-04-23 13:26:53 +01:00
|
|
|
sudo lsof -t -i:8000
|
|
|
|
# List files and proces ID (-t) and internet connections (-i) on port number
|
|
|
|
|
|
|
|
$ 7890
|
|
|
|
# Gives you process id
|
|
|
|
|
|
|
|
sudo kill -9 7890
|
|
|
|
# Kill the process that is running there
|
2022-09-06 15:44:40 +01:00
|
|
|
```
|
2024-03-17 11:00:04 +00:00
|
|
|
|
|
|
|
## Alterntive
|
|
|
|
|
|
|
|
```sh
|
|
|
|
ss -ltnp | grep ':8000'
|
|
|
|
```
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
```
|
|
|
|
LISTEN 0 511 [::1]:8000 [::]:* users:(("node",pid=10493,fd=34))
|
|
|
|
```
|
|
|
|
|
|
|
|
Kill with:
|
|
|
|
|
|
|
|
```
|
|
|
|
kill 10493
|
|
|
|
```
|