Junior — Middle
How can you determine occupied ports on a server using Bash?
sobes.tech AI
Answer from AI
To identify occupied ports on a server in Bash, you can use several commands:
netstat -tuln— shows all listening TCP and UDP ports.ss -tuln— a modern alternative to netstat, displays a list of listening ports.lsof -i— shows open network connections and ports.
Example usage:
sudo netstat -tuln | grep LISTEN
This command will output a list of all ports that are in the listening state (occupied by server applications).