1.通过端口查看进进程
1.linux查看命令
方法1:
[root@artifactory-no ~]# netstat -nap |grep 8082 #这里的8082就是我们要查看端口号,11901就是占有这个端口号的进程号 tcp6 0 0 :::8082 :::* LISTEN 11901/java tcp6 0 0 172.31.46.87:8082 10.5.123.56:57816 ESTABLISHED 11901/java tcp6 0 0 172.31.46.87:8082 10.5.123.56:57815 ESTABLISHED 11901/java tcp6 0 0 172.31.46.87:8082 10.5.123.56:57819 ESTABLISHED 11901/java tcp6 0 0 172.31.46.87:8082 10.5.123.56:57820 ESTABLISHED 11901/java
[root@artifactory-no ~]# ps -ef |grep 11901 #这里通过进程号,查看具体进程,下面红色加粗字段就是我们要查的进程
root 11901 1 0 Jan02 ? 1-04:29:39 /disk1/jdk/jdk1.8.0_151/bin/java -jar ipackage.jar
root 22191 22030 0 11:23 pts/1 00:00:00 grep --color=auto 11901
方法2:
[root@artifactory-no ~]# lsof -i:8082 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 11901 root 23u IPv6 17449717 0t0 TCP *:us-cli (LISTEN) java 11901 root 40u IPv6 43056193 0t0 TCP artifactory-no.01.novalocal:us-cli->10.5.123.56:57815 (ESTABLISHED) java 11901 root 42u IPv6 43056202 0t0 TCP artifactory-no.01.novalocal:us-cli->10.5.123.56:57816 (ESTABLISHED) java 11901 root 45u IPv6 43056203 0t0 TCP artifactory-no.01.novalocal:us-cli->10.5.123.56:57819 (ESTABLISHED) java 11901 root 46u IPv6 43056204 0t0 TCP artifactory-no.01.novalocal:us-cli->10.5.123.56:57820 (ESTABLISHED) [root@artifactory-no ~]# ps -ef |grep 11901 root 11901 1 0 Jan02 ? 1-04:29:44 /disk1/jdk/jdk1.8.0_151/bin/java -jar ipackage.jar
2.windows命令
首先我们通过win+r的方式进入cmd或者powershell界面
PS C:Usersoliu16> netstat -ano |findstr "443" #这里的443就是我们要查询的端口,6716就是我们要查的进程号 TCP 0.0.0.0:443 0.0.0.0:0 LISTENING 6716 TCP 0.0.0.0:44343 0.0.0.0:0 LISTENING 5080 TCP 10.5.23.125:54324 40.90.189.152:443 ESTABLISHED 5508 TCP 10.5.23.125:54341 54.70.109.38:443 ESTABLISHED 5564 TCP 10.5.23.125:55181 23.45.204.16:443 CLOSE_WAIT 10192 TCP 10.5.23.125:60326 203.208.50.65:443 TIME_WAIT 0 TCP 10.5.23.125:60328 117.41.244.205:443 TIME_WAIT 0 TCP 10.5.23.125:60330 58.49.137.9:443 TIME_WAIT 0 TCP 10.5.23.125:60332 117.41.244.205:443 TIME_WAIT 0 TCP 10.5.23.125:60351 113.105.172.38:443 TIME_WAIT 0 TCP 10.5.23.125:60355 42.101.56.38:443 TIME_WAIT 0 TCP 10.5.23.125:60359 115.231.41.38:443 TIME_WAIT 0 TCP 10.5.23.125:60360 115.231.41.38:443 TIME_WAIT 0 TCP 10.5.23.125:60364 115.231.41.38:443 TIME_WAIT 0 TCP 10.5.23.125:60367 115.231.41.38:443 TIME_WAIT 0 TCP 10.5.23.125:60368 115.231.41.38:443 TIME_WAIT 0 TCP 10.5.23.125:60373 115.231.41.38:443 TIME_WAIT 0
。。。。。。。。。
PS C:Usersoliu16> tasklist |findstr "6716" #这里的vmware-hostd.exe就是我们要查的进程
vmware-hostd.exe 6716 Services 0 21,816 K
2.通过进程号查看端口号
1.windows命令
netstat -ano | findstr pid号码
2.linux命令
netstat -nap | grep 进程号
3.杀死进程的方式
1.linux命令
[root@artifactory-no ~]# kill -9 "进程号"
2.windows命令
taskkill /f /t /im "进程id或者进程名称"
这些都是强制杀死进程的方式,不推荐使用,停进程服务,推荐使用自带的脚本进行启停
4.通过进程号查看进程的运行路径
1.windows命令查看
PS C:UsersAdministrator> wmic #这里先输入wmic命令,然后回车 wmic:rootcli>process where processid=1564 get processid,executablepath,name #这里1564就是要查的进程号,ExecutablePath下面的路径就是我们要查看的运行路径 ExecutablePath Name ProcessId C:Program Filesabbix Agentzabbix_agentd.exe zabbix_agentd.exe 1564
2.linux命令查看
[root@artifactory-no ~]# ll /proc/11901/ #这里的11901就是进程号 total 0 dr-xr-xr-x 2 root root 0 Jul 9 11:09 attr -rw-r--r-- 1 root root 0 Jul 9 14:34 autogroup -r-------- 1 root root 0 Jul 9 14:34 auxv -r--r--r-- 1 root root 0 Jul 9 14:34 cgroup --w------- 1 root root 0 Jul 9 14:34 clear_refs -r--r--r-- 1 root root 0 Jan 2 2020 cmdline #这里是进程启动命令 -rw-r--r-- 1 root root 0 Jul 9 14:34 comm -rw-r--r-- 1 root root 0 Jul 9 14:34 coredump_filter -r--r--r-- 1 root root 0 Jul 9 14:34 cpuset lrwxrwxrwx 1 root root 0 Jul 9 14:34 cwd -> /disk1/ipackage #链接到进程当前工作目录 -r-------- 1 root root 0 Jul 9 14:34 environ #进程环境变量列表 lrwxrwxrwx 1 root root 0 Jan 2 2020 exe -> /disk1/jdk/jdk1.8.0_151/bin/java #链接到进程的执行命令文件 dr-x------ 2 root root 0 Jul 9 11:09 fd #包含进程相关的所有的文件描述符 dr-x------ 2 root root 0 Jul 9 11:17 fdinfo -rw-r--r-- 1 root root 0 Jul 9 14:34 gid_map -r-------- 1 root root 0 Jul 9 14:34 io -r--r--r-- 1 root root 0 Jul 9 14:34 limits -rw-r--r-- 1 root root 0 Jul 9 14:34 loginuid dr-x------ 2 root root 0 Jul 9 14:34 map_files -r--r--r-- 1 root root 0 Jan 2 2020 maps #与进程相关的内存映射信息 -rw------- 1 root root 0 Jul 9 14:34 mem #指代进程持有的内存,不可读 -r--r--r-- 1 root root 0 Jul 9 14:34 mountinfo -r--r--r-- 1 root root 0 Jul 9 14:34 mounts -r-------- 1 root root 0 Jul 9 14:34 mountstats dr-xr-xr-x 6 root root 0 Jan 2 2020 net dr-x--x--x 2 root root 0 Jul 9 14:34 ns -r--r--r-- 1 root root 0 Jul 9 14:34 numa_maps -rw-r--r-- 1 root root 0 Jul 9 14:34 oom_adj -r--r--r-- 1 root root 0 Jul 9 14:34 oom_score -rw-r--r-- 1 root root 0 Jul 9 14:34 oom_score_adj -r--r--r-- 1 root root 0 Jul 9 14:34 pagemap -r--r--r-- 1 root root 0 Jul 9 14:34 personality -rw-r--r-- 1 root root 0 Jul 9 14:34 projid_map lrwxrwxrwx 1 root root 0 Jul 9 14:34 root -> / #链接到进程的根目录 -rw-r--r-- 1 root root 0 Jul 9 14:34 sched -r--r--r-- 1 root root 0 Jul 9 14:34 schedstat -r--r--r-- 1 root root 0 Jul 9 14:34 sessionid -rw-r--r-- 1 root root 0 Jul 9 14:34 setgroups -r--r--r-- 1 root root 0 Jul 9 14:34 smaps -r--r--r-- 1 root root 0 Jul 9 14:34 stack -r--r--r-- 1 root root 0 Jan 2 2020 stat #进程的状态 -r--r--r-- 1 root root 0 Jul 9 14:34 statm -r--r--r-- 1 root root 0 Jan 2 2020 status #进程状态信息,比stat/statm更具可读性 -r--r--r-- 1 root root 0 Jul 9 14:34 syscall dr-xr-xr-x 90 root root 0 Jul 9 14:34 task -r--r--r-- 1 root root 0 Jul 9 14:34 timers -rw-r--r-- 1 root root 0 Jul 9 14:34 uid_map -r--r--r-- 1 root root 0 Jul 9 14:34 wchan