how to list and kill processes accessing internet in linux

2

How to kill the processes accessing Internet in background using terminal commands. Command to stop (disconnect) the processes accessing Internet. Command to kill the process accessing Internet.

JOHN

Posted 2011-07-28T00:37:19.467

Reputation: 285

kill -9 'name_of_program_using_internet' – Nicholi – 2011-07-28T00:43:19.413

@Nicholi : But how to find processes accessing internet ? – JOHN – 2011-07-28T00:50:10.840

3kill -15 is preferable, since programs designed to respond to the 15 argument will clean up before ending. – myopic.bones – 2011-07-28T00:59:48.967

Answers

4

To find any processes making/listening for Internet connections run:

lsof -i

Output will be similar to this:

COMMAND     PID   USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
sshd       4236   root    3u  IPv4   13169      0t0  TCP *:ssh (LISTEN)
ntpd       4260    ntp   16u  IPv4   13192      0t0  UDP *:ntp 
ntpd       4260    ntp   17u  IPv4   13196      0t0  UDP localhost:ntp 
ntpd       4260    ntp   18u  IPv4   13197      0t0  UDP 127.0.0.2:ntp 
master     4431   root   12u  IPv4   13397      0t0  TCP localhost:smtp (LISTEN)
httpd2-pr  4493   root    3u  IPv4   13542      0t0  TCP *:http (LISTEN)

Now use kill with the PID of the processes as listed above, for example, to kill ssh above, run:

sudo kill -15 4236

If that doesn't help, run:

sudo kill -9 4236

Option -15 sends a TERM signal, which kindly asks the process to quit. Option -9 sends a KILL signal, which forces the process to immediately quit. Try -15 first, then -9.

Nicholi

Posted 2011-07-28T00:37:19.467

Reputation: 628