There are several ways to find out which ports are open on a Linux system using the command line. Here are a few options:
netstat command: The netstat command can be used to list all open ports on a Linux system. Use the -tulpn options to display the TCP, UDP, and listening ports. For example:$ netstat -tulpn
lsof command: The lsof (List Open Files) command can be used to display a list of all open network sockets on a Linux system. To list all open TCP and UDP ports, use the -i option followed by the protocol (TCP or UDP). For example:$ lsof -i TCP $ lsof -i UDP
ss command: The ss command is another utility that can be used to list all open sockets on a Linux system. To list all open TCP and UDP ports, use the -t and -u options respectively. For example:$ ss -t $ ss -u
You can also use the grep command to filter the output of these commands to find a specific port. For example, to find if port 80 is open, you can use the following command:
$ netstat -tulpn | grep :80