From 845b012e722d6d2ebe99cb42a153040fc341626d Mon Sep 17 00:00:00 2001 From: LouisFonda Date: Sun, 14 Jul 2024 13:39:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=BB=98=E8=AE=A4=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=A3=80=E6=B5=8B=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tutorials/basic/12-port-check.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tutorials/basic/12-port-check.sh diff --git a/tutorials/basic/12-port-check.sh b/tutorials/basic/12-port-check.sh new file mode 100644 index 0000000..d8a8903 --- /dev/null +++ b/tutorials/basic/12-port-check.sh @@ -0,0 +1,27 @@ +#!/bin/bash +#Program: +# 检查机器的开放服务,比如Http服务(80), https服务(443),ssh服务(22),邮箱服务(25) +#History: +# 2024/07/14 LouisFonda + +testfile=/dev/shm/netstat_checking.txt # 保存端口信息到内存 +netstat -tunl > ${testfile} + +echo -e "本机开通了如下服务" + +testing=$(grep ":80" ${testfile}) +if [ "${testing}" != "" ]; then + echo "http服务" +fi +testing=$(grep ":443" ${testfile}) +if [ "${testing}" != "" ]; then + echo "https服务" +fi +testing=$(grep ":22" ${testfile}) +if [ "${testing}" != "" ]; then + echo "ssh服务" +fi +testing=$(grep ":25" ${testfile}) +if [ "${testing}" != "" ]; then + echo "email服务" +fi \ No newline at end of file