Linux: find out who has file open or is using a port
February 11, 2010 05:07:48 Last update: February 11, 2010 05:08:20
On Linux, you can use the fuser command to find out who has a file open, or is using a port. For example, if you start Tomcat and get the error "Address already in use: 8080", you want to know which process is already binding to port 8080.
# list processes on port 8080 fuser 8080/tcp # verbose mode fuser -v 8080/tcp # kill the processes accessing port 8080 fuser -k 8080/tcp # show all processes at the (local) TELNET port fuser telnet/tcp # list processes using /mnt/usb1 with user name fuser -m -u /mnt/usb1 # list process IDs and user names for processes using the current directory fuser -fu .