By using lsof (included with Linux, available from Skunkware for old SCO).
For example, if you wanted to know what process is using port 139, you'd do:
lsof -i :139
The lsof tool is not just for network connections. It shows you detailed information about open files in general- not just network activity.
See lsof also.
Got something to add? Send me email.
Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do. (Donald Knuth)