List Open Ports in Linux
The short answer
In Linux, to get the list of open ports on your local machine, you can use the netstat command as follows:
$ netstat -tulnWhere:
- The -t flag is used to show TCP ports.
- The -u flag is used to show UDP ports.
- The -l flag is used to only show open ports.
- The -n flag is used to show IP addresses and port numbers.
For example:
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
udp 0 0 0.0.0.0:68 0.0.0.0:*Note that the netstat command is available in the net-tools package.
Easily retrieve these commands using Warp's AI Command Suggestions feature
If you’re using Warp as your terminal, you can easily retrieve this command using the Warp AI Command Suggestions feature:

Entering linux list open ports in the AI Command Suggestions will prompt a netstat command that can then quickly be inserted into your shell by doing CMD+ENTER.
Related articles
Bash Comments
Comments will help make your scripts more readable
Reading User Input
Via command line arguments and prompting users for input
Curl Post Request
Use cURL to send data to a server
Upload Files With curl
Learn how to upload a file to FTP, SFTP servers, Artifactory, and AWS S3 using the curl command.
How To Copy A Directory In Linux
Learn how to copy directories and their content in Linux using the cp command with options like -r for recursive copying, -i for interactive mode, and -a for preserving attributes.
Create Groups In Linux
Learn how to manually and automatically create and list groups in Linux.
How to Check the Size of Folders in Linux
Learn how to output the size of directories and subdirectories in a human-readable format in Linux and macOS using the du command.
Count Files in Linux
Learn how to count files and folders contained in directories and subdirectories in Linux using the ls, find, and wc commands.
Format Command Output In Linux
Learn how to filter and format the content of files and the output of commands in Linux using the awk command.
Create Directories Recursively With mkdir
Learn how to recursively create nested directories using the mkdir command, Bash scripts, and Python scripts.
Remover Users in Linux
Learn how to remove local and remote user accounts and associated groups and files in Linux using the userdel and deluser commands.
Switch Users In Linux
Learn how to switch between users, log in as another user, and execute commands as another user in Linux.