Debian查看端口占用的进程,并杀死进程

原文地址为: Debian查看端口占用的进程,并杀死进程

  1. netstat -tlnp|grep 8000

  • tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN      7577/python 
  • 7577就是进程号

  1. $ kill -s 9 1827

其中-s 9 制定了传递给进程的信号是9,即强制、尽快终止进程。
改进1:
把ps的查询结果通过管道给grep查找包含特定字符串的进程。管道符“|”用来隔开两个命令,管道符左边命令的输出会作为管道符右边命令的输入。
$ ps -ef | grep firefox
smx       1827     1  4 11:38 ?        00:27:33 /usr/lib/firefox-3.6.18/firefox-bin
smx      12029  1824  0 21:54 pts/0    00:00:00 grep --color=auto firefox
这次就清爽了。然后就是
$kill -s 9 1827

改进2——使用pgrep:
一看到pgrep首先会想到什么?没错,grep!pgrep的p表明了这个命令是专门用于进程查询的grep。
$ pgrep firefox
1827
看到了什么?没错火狐的PID,接下来又要打字了:
$kill -s 9 1827


转载请注明本文地址: Debian查看端口占用的进程,并杀死进程

猜你喜欢

转载自blog.csdn.net/kkwant/article/details/80927545
今日推荐