eg:
netstat -nlp | grep 3001查询结果:
1.1.1 -anp netstat -anp | grep 端口号eg:
netstat -anp | grep 3001查询结果:
1.2、netstat 参数解析 usage: netstat [-veenNcCF] [<Af>] -r netstat {-V|--version|-h|--help} netstat [-vnNcaeol] [<Socket> ...] netstat { [-veenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s } [delay] -r, --route display routing table #显示路由表 -I, --interfaces=<Iface> display interface table for <Iface> #显示网络接口表 -i, --interfaces display interface table #显示网络接口表 -g, --groups display multicast group memberships #显示多播组成员 -s, --statistics display networking statistics (like SNMP) #显示网络统计数据,如IP/ICMP/SNMP/..各协议统计。 -M, --masquerade display masqueraded connections #显示伪装的连接 -v, --verbose be verbose #详细信息 -n, --numeric don't resolve names #不做名字解析,不加此参数,80端口会显示成http,127.0.0.1显示成localhost,uid为0显示成root等等 --numeric-hosts don't resolve host names #不做主机名解析 --numeric-ports don't resolve port names #不做端口名解析 --numeric-users don't resolve user names #不做用户名解析 -N, --symbolic resolve hardware names -e, --extend display other/more information #显示更多信息,用户名,inode -p, --programs display PID/Program name for sockets #显示pid和程序名字 -c, --continuous continuous listing #持续的列出相关信息 -l, --listening display listening server sockets #显示处于监听状态的套接字 -a, --all, --listening display all sockets (default: connected) #显示所有的套接字 -o, --timers display timers #显示计时器 -F, --fib display Forwarding Information Base (default) #使用-rF查看路由表时,显示转发信息 -C, --cache display routing cache instead of FIB #使用-rC查看路由表时,显示详细的路由缓存 -T, --notrim stop trimming long addresses #停止修剪长地址 -t #显示tcp链接 -Z, --context display SELinux security context for sockets #显示套接字的SELINUX上下文-u #显示udp链接-x #显示unix套接字 <Iface>: Name of interface to monitor/list. <Socket>={-t|--tcp} {-u|--udp} {-S|--sctp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom <AF>=Use '-A <af>' or '--<af>'; default: inet List of possible address families (which support routing): inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) x25 (CCITT X.25) 2、lsof 命令 2.1、查看端口进程 lsof -i:端口号eg:
lsof -i:3001查询结果:
2.2、lsof 参数解析lsof语法格式是: lsof [options] filename
常用的参数列表:
如果想详细查看这个进程,ID具体是哪一个进程,可以通过ps命令查看进程的详细信息。
ps -ef| grep 24809eg:
ps -ef| grep 24809查询结果:
3.1.1 ps 参数解析使用方式:ps [options] [–help]
常用参数:
通过 ll [option] 可以查看、可以快速定位到进程的目录。
ll /proc/进程ID/cwdeg:
ll /proc/24809/cwd查询结果: