# Check If A Port Is In Use

We can check if a port is in use or not, by following ways in Linux.

## Option 1

`lsof`

```bash
sudo lsof -i -P -n | grep LISTEN
```

Also, we can check a specific port by running -

```bash
sudo lsof -i:{PORT_NUMBER}
```

## Option 2

`netstat`

```bash
sudo netstat -tulpn | grep LISTEN
```

## Option 3

`nmap`

```bash
sudo nmap -sTU -O {IP_ADDRESS}
```

***Source:*** [***CyberCiti***](https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.devjugal.com/linux/check-if-a-port-is-in-use.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
