LoginSignup
0
0

More than 3 years have passed since last update.

ポートの操作

Posted at

Linuxでプロセスが何のポートを使っているかを確認して、キルするまでの流れ

現在使用しているプロセスの内容確認

$ ps r
//PIDがボートID
PID   TT  STAT      TIME COMMAND
26821 s007  Ss     0:00.08 /bin/bash -l
26559 s006  S+     0:14.53 node /Users/.../node_modules/.bin/xxxxx
26526 s006  S+     0:00.41 npm   
26247 s006  Ss     0:00.02 /bin/bash -l
26189 s005  S+     0:15.90 node /Users/.../node_modules/.bin/xxxxx
26526 s006  S+     0:00.41 npm   
26156 s005  S+     0:00.39 npm

ポート番号から使用しているプログラムを表示する

//これで使っているプログラムのPIDがわかる
$ lsof -i:9000
COMMAND   PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
node    25687   xxxx   00x  IPv4 xxxxxxxxx      0x0  TCP localhost:xxxxxx (LISTEN)

PIDを使ってプログラムを調べる

$ ps -afx | grep 25687
  502 25687 25654   0  1:59PM txyx001    0:17.05 node /Users/.../node_modules/.bin/xxxxx
  502 30827 26821   0  4:48PM txyx000    0:00.00 grep 25687

プロセスをキルする

$ kill 25687
xx-x-xxxxx:xxxxx_xxx xxxxx$ ps -afx | grep 25687
  502 30838 26821   0  4:48PM txyx000    0:00.00 grep 25687

以上

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0