I want to know which ports are used by which processes in embedded-linux.Since it is simple embedded-linux, there are no network command lines such as netstat, lsof.(only basic command lines such as cat, cp, echo, etc exist).A partial solution seems to be to use cat /proc/net/tcp and cat /proc/net/udp command lines.However, I am not sure the printed list from those command lines shows all ports in use, and the list does not show which process is binded to certain port.Any comments would be appreciated.
WITHOUT using network command lines in linux, how to know list of open ports and the process that owns them?
linux;networking;process;tcp
You should be able to find all open ports in /proc/net/tcp and /proc/net/udp. Each of those files have an inode column, which can be used to find the process owning that socket.Once you have an inode number, you can run an ls command such as ls -l /proc/*/fd/* | grep socket:.$INODE to find the processes using that socket. In case a process has been set up with different file descriptors for different threads, you may need to extend the command to ls -l /proc/*/task/*/fd/* | grep socket:.$INODE in order to find them all.