lsof and pwdx
lsof is used to list open files (e.g. lsof /tmp) but can also be used to
list open ports. Once you know what pid holds the open port you’re interested
in, there are a few different tools to figure out what the process actually
is.
- lsof -i TCP:1234returns the pid of the process with the given port open.
- If psor (for Java programs)jpsdon’t give a useful program name,pwdxcan be used to find the program’s working directory, which can be useful.