IT袋

当前位置:主页 > 经验教程 > 系统教程 >

linux服务器重启命令

linux服务器重启命令 自己搭建小型服务器(2)

更新:2023-08-26 02:08:08 来源:IT袋 作者:苏晓敏
导读:linux服务器重启命令,要只显示 TCP 端口,使用  --all 和 --tcp 参数,或者简写成 -at : $ netstat -at | head -n 5Active Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Fore

linux服务器重启命令

要只显示 TCP 端口,使用 --all--tcp参数,或者简写成-at

$ netstat -at | head -n 5Active Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:27036 *:* LISTEN tcp 0 0 localhost:27060 *:* LISTEN tcp 0 0 *:16001 *:* LISTEN

要只显示 UDP 端口,使用 --all--udp参数,或者简写成-au

$ netstat -au | head -n 5Active Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address State udp 0 0 *:27036 *:* udp 0 0 10.0.1.222:44741 224.0.0.56:46164 ESTABLISHEDudp 0 0 *:bootpc

netstat命令参数常常是简单易懂的。举个例子,要显示带有全部进程 ID(PID)和数字地址的监听 TCP 和 UDP 的端口:

$ sudo netstat --tcp --udp --listening --programs --numericActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Addr State PID/Program name tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2500/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1726/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1721/cupsd tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 4023/sshd: tux@ tcp6 0 0 :::111 :::* LISTEN 1/systemd tcp6 0 0 :::22 :::* LISTEN 1726/sshd tcp6 0 0 ::1:631 :::* LISTEN 1721/cupsd tcp6 0 0 ::1:6010 :::* LISTEN 4023/sshd: tux@ udp 0 0 0.0.0.0:40514 0.0.0.0:* 1499/avahi-daemon: udp 0 0 192.168.122.1:53 0.0.0.0:* 2500/dnsmasq udp 0 0 0.0.0.0:67 0.0.0.0:* 2500/dnsmasq udp 0 0 0.0.0.0:111 0.0.0.0:* 1/systemd udp 0 0 0.0.0.0:5353 0.0.0.0:* 1499/avahi-daemon: udp6 0 0 :::111 :::* 1/systemd udp6 0 0 :::44235 :::* 1499/avahi-daemon: udp6 0 0 :::5353 :::* 1499/avahi-daemon:

这个常用组合简写版本是 -tulpn

要显示一个指定服务的信息,使用 grep 命令过滤:

$ sudo netstat -anlp | grep cupstcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1721/cupsd tcp6 0 0 ::1:631 :::* LISTEN 1721/cupsdunix 2 [ ACC ] STREAM LISTENING 27251 1/systemd /var/run/cups/cups.sockunix 2 DGRAM 59530 1721/cupsdunix 3 STREAM CONNECTED 55196 1721/cupsd /var/run/cups/cups.sock

相关阅读