List Open Ports in Linux
[#list-open-ports] The short answer [#list-open-ports]
In Linux, to get the list of open ports on your local machine, you can use the [.inline-code]netstat[.inline-code] command as follows:
Where:
- The [.inline-code]-t[.inline-code] flag is used to show TCP ports.
- The [.inline-code]-u[.inline-code] flag is used to show UDP ports.
- The [.inline-code]-l[.inline-code] flag is used to only show open ports.
- The [.inline-code]-n[.inline-code] flag is used to show IP addresses and port numbers.
For example:
Note that the [.inline-code]netstat[.inline-code] command is available in the [.inline-code]net-tools[.inline-code] package.
[#easily-recall-commands-with-ai] Easily retrieve these commands using Warp's AI Command Suggestions feature [#easily-recall-commands-with-ai]
If you’re using Warp as your terminal, you can easily retrieve this command using the Warp AI Command Suggestions feature:
![](https://cdn.prod.website-files.com/64b7506ad75bbfcf43a51e90/66903f9abfe0f7f811c92663_AD_4nXePe6cA02DtDwxV2j5888FTHbdbiIiJXKQxrOuzNV3LKqadBUcUEH98Fquoy-pJ09Hfh8Qo6pnBakFjxlDS4DW3es99PYTESSlwlm3itoMWL8hLfVMjeynFy1xlkkoyLtdxTjggQMKsrFPVM0LRl_vk5eM.gif)
Entering [.inline-code]linux list open ports[.inline-code] in the AI Command Suggestions will prompt a [.inline-code]netstat[.inline-code] command that can then quickly be inserted into your shell by doing [.inline-code]CMD+ENTER[.inline-code].