curl -O https://example.com/file.zip # 下載並保留原檔名
curl -L -o newname.zip https://example.com/f # 跟隨重導向、指定檔名
curl -X POST -H "Content-Type: application/json" -d '{"k":"v"}' https://api.example.com
wget https://example.com/file.zip # 簡單下載
wget -c https://example.com/big.iso # 斷點續傳
ping -c 4 8.8.8.8
ping -i 0.2 -c 20 192.168.1.1 # 高頻測試抖動
tracepath 8.8.8.8 # 無需 root,Ubuntu 預裝
traceroute 8.8.8.8 # 需安裝,功能更豐富
輸出每躍點 IP、主機名、RTT,定位網路斷點或高延遲節點。
mtr 8.8.8.8
mtr -r -c 10 8.8.8.8 # 報告模式,執行 10 次後輸出統計
結合 ping + traceroute,持續更新每躍點遺失率與延遲。
host example.com # A/AAAA 記錄
host 8.8.8.8 # 反向查詢 PTR
host -t mx example.com # MX 記錄
host -t ns example.com # NS 記錄
dig example.com +short # 簡潔輸出
dig @1.1.1.1 example.com # 指定 DNS 伺服器
whois example.com
whois 8.8.8.8
顯示註冊商、建立/到期日、Name Server、持有者資訊(部分隱私保護)。
| ifconfig (舊) | ip (新,iproute2) |
|---|---|
ifconfig | ip addr show / ip a |
ifconfig eth0 up | ip link set eth0 up |
ifconfig eth0 192.168.1.10/24 | ip addr add 192.168.1.10/24 dev eth0 |
ifconfig eth0 down | ip link set eth0 down |
建議改用 ip 指令,功能更完整、輸出可機器解析。
ss -tuln # 所有 TCP/UDP 監聽埠
ss -tulpn # 顯示 PID/程式名
ss -s # 統計摘要
ss state established sport = :22 # 過濾條件
優點:速度快、支援過濾語法、核心直接讀取。
# 傳統 ifupdown (Debian/Ubuntu Server)
sudo ifup eth0
sudo ifdown eth0
# NetworkManager (桌面版、現代 Server)
nmcli device status
nmcli connection up id "Wired connection 1"
nmcli device wifi connect "SSID" password "passwd"
sudo dhclient -r # 釋放目前 IP
sudo dhclient eth0 # 重新取得 IP
sudo dhclient -v eth0 # 詳細過程
netstat -tulnp # 監聽埠 + PID
netstat -rn # 路由表
netstat -s # 協定統計計數器
netstat -i # 介面統計
| 需求 | 推薦指令 |
|---|---|
| 下載/測試 HTTP API | curl |
| 基本連通 | ping |
| 定位路由問題 | mtr / tracepath |
| DNS 除錯 | dig / host |
| 查看/設定 IP | ip addr / ip link |
| 查看連線/監聽埠 | ss -tulpn |
| 管理 Wi-Fi/連線 | nmcli |
| DHCP 重新取得 IP | dhclient |