Junior — Middle
How can you determine the list of open ports in the operating system using Bash commands?
sobes.tech AI
Answer from AI
To determine the list of open ports in the operating system using Bash commands, you can use several utilities:
-
netstat:
netstat -tulnShows all listening TCP and UDP ports.
-
ss (modern replacement for netstat):
ss -tuln -
lsof:
sudo lsof -i -P -n | grep LISTENShows processes that are listening on ports.
-
nmap (if you need to scan the local machine):
nmap -sT -O localhost
These commands will help you get a list of open and listening ports in the system.