---
title: "lsof - local open ports"
date: "2019-03-14T23:42:02Z"
lastmod: "2019-03-14T23:42:02Z"
authors:
  - "utzer"
tags:
  - "grep"
  - "lsof"
  - "netstat"
  - "ports"
categories:
  - "Linux"
canonical_url: "https://newblog.utzer.de/2019/03/15/lsof-local-open-ports/"
---

A short one:

### Command

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

This will output all the ports the system is listing on. You might have to prepend "sudo".

So then the command will be:

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

The list is long without the "grep", it will filter the output and only show the lines which contain "LISTEN".

Edit:  
Oliver from [Hubzilla](https://fediverse.party/en/hubzilla/) (part of the [Fediverse](https://fediverse.party/en/fediverse/)) pointed out that

```
netstat -anpl
```

might be helpful too. The command shows all the listing sockets of the Linux machine it is run on. (I added the "l" parameter to just show listing sockets.

