Hi 你們好,我是鍾義林,你們查看端口的的方式有以下命令linux
windows cmdwindows
netstat -aon | findstr "端口號"bash
linuxssh
netstat -anl | grep "端口號"ide
lsof -i:端口號this
可是,你又到這樣的問題嗎?spa
-bash: lsof: command not founddebug
lsof 命令不能用,我找了一下,網上說的方法多少都行不經過,今天給你們說下個人解決方法ci
yum install lsof -ycmd
======================================================================================
[root@Evil ~]# lsof -i:3306
-bash: lsof: command not found
[root@Evil ~]# yum install lsof
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package lsof.x86_64 0:4.82-4.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================
Package Arch Version Repository Size
=======================================================================================
Installing:
lsof x86_64 4.82-4.el6 base 319 k
Transaction Summary
=======================================================================================
Install 1 Package(s)
Total download size: 319 k
Installed size: 890 k
Is this ok [y/N]: y
Downloading Packages:
lsof-4.82-4.el6.x86_64.rpm | 319 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : lsof-4.82-4.el6.x86_64 1/1
Verifying : lsof-4.82-4.el6.x86_64 1/1
Installed:
lsof.x86_64 0:4.82-4.el6
Complete!
[root@Evil ~]# lsof -i:3306
[root@Evil ~]# lsof -i:22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 3044 root 3u IPv4 32288 0t0 TCP *:ssh (LISTEN)
sshd 3044 root 4u IPv6 32290 0t0 TCP *:ssh (LISTEN)
sshd 9243 root 3r IPv4 50830 0t0 TCP 192.168.1.234:ssh->192.168.1.1:33540 (ESTABLISHED)