CentOS 最小安裝不含 whois 指令,直接 yum install whois 找不到套件。需透過 yum search 或 yum whatprovides 找到提供 /usr/bin/whois 的套件名稱 jwhois。
# 方法 1: search (搜尋名稱/描述)
yum search whois
# 輸出: jwhois.x86_64 : Internet whois/nicname client
# 方法 2: whatprovides (搜尋提供的檔案) - 更精確
yum whatprovides '*/bin/whois'
# 或
yum whatprovides whois
# 輸出: jwhois-4.0-18.el6.x86_64 : Internet whois/nicname client
# Filename: /usr/bin/whois
sudo yum install -y jwhois
# 完成後 /usr/bin/whois 即可用 (jwhois 提供 whois 符號連結)
which whois
# /usr/bin/whois
whois google.com
# 輸出域名註冊資訊、DNS 伺服器、到期日等
whois 8.8.8.8
# 輸出 IP 區塊分配資訊
# 指定 whois 伺服器
whois -h whois.verisign-grs.com google.com
# 顯示完整回應 (不截斷)
whois -v google.com
# 批次查詢
for domain in google.com github.com linux.org; do
echo "=== $domain ==="
whois $domain | head -20
done
jwhois-*.rpm → rpm -ivh./configure && make && make installrdap (Registration Data Access Protocol) 客戶端,支援 JSON 輸出#!/bin/bash
# check_domain_expiry.sh
DOMAIN=$1
EXPIRY=$(whois $DOMAIN | grep -iE 'expir|expire|paid-till' | head -1 | sed 's/.*: //')
echo "$DOMAIN expires: $EXPIRY"
# 整合至監控系統 (Zabbix/Prometheus/Alertmanager)
掌握 yum whatprovides '*/bin/命令' 技巧,可快速解決任何「指令不存在、不知屬於哪個套件」的安裝難題。