How to check the port number occupied by a process in Linux?
There are various ways to view the port numbers occupied by processes in Linux. Here are some common methods:
- Utilize the netstat command:
- show only the listening ports using the netstat command.
- This command will display all the listening ports and their corresponding processes.
- Use the lsof command:
- lsof -i :port number
- Replace the port number with the specific port number, this command will display the process information associated with that port number.
- Use the ss command:
- Show all listening sockets
- This command will display all the TCP ports that are being listened to, along with the corresponding processes.
These commands need to be executed using root or a user with root permissions, regardless of the method.