4 ms·
`fuser` (from `psmisc`[0] Linux package; commonly installed IME, also supplies things like `pstree`) lets you identify processes which have files or sockets ope
by darrenf 3y ago
`fuser` (from `psmisc`[0] Linux package; commonly installed IME, also supplies things like `pstree`) lets you identify processes which have files or sockets open, and has a `-k` switch for killing them. So you can run e.g.
fuser -k 8080/tcp # kill processes with TCP :8080 open, IPv4 and IPv6
fuser -k -6 8080/tcp # same but IPv6 only
fuser -k 8080/udp # UDP instead of TCP
[0] https://gitlab.com/psmisc/psmisc https://gitlab.com/psmisc/psmisc
- mattlondon 3y agofuser is so handy - I am surprised more people do not know about it. It is one of my favourite tricks when pair programming etc. You can also use it to kill processes that have a file open too, which is also handy if your hung server is also hanging onto files as well as ports.
- zelphirkalt 3y agoDoes this also release the port? I sometimes have an application listen on a port and when I kill it, the port is still reserved or blocked for a minute or two.