今天進度 : 鳥哥的 Linux 私房菜 -- 區域網路的環境設定
測試開放外網的時候,使用 netstat -tlunp
追查開放的 port 的服務
test@test:~$ netstat -tlunp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:43769 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
udp 0 0 127.0.0.53:53 0.0.0.0:* -
udp 0 0 172.20.175.32:68 0.0.0.0:* -
找到對應的啟動腳本,進行停用
test@test:~$ cd /etc/init.d/
test@test:/etc/init.d$ ls
apparmor cgroupfs-mount cryptdisks grub-common iscsid lvm2 open-iscsi plymouth-log rsyslog ubuntu-fan unattended-upgrades
apport console-setup.sh cryptdisks-early hwclock.sh keyboard-setup.sh lvm2-lvmpolld open-vm-tools procps screen-cleanup udev uuidd
atd cron dbus irqbalance kmod multipath-tools plymouth rsync ssh ufw
結合昨天學的 bash 功能,批量停用
#!/bin/bash
services="想停用的服務" # 像是 "NetworkManager autofs "
for service in ${services}
do
echo 'stop' ${service} 'service'
/etc/init.d/${service} stop
done
批量 for each 例子
#!/bin/bash
arr="1 2 3 4 5 6 7 8 9"
for a in $arr
do
echo $a
done
明天進度 : 鳥哥的 Linux 私房菜 -- DRBL 與 Clonezilla 再生龍