问题描述
在尝试使用 ping 命令来检查与 GitHub 的网络连接时,遇到了错误,提示“Name or service not known”。这个错误的原因是 ping 命令不能接受包含 https:// 的 URL 作为参数,它只能使用主机名或IP地址。
root@autodl-container-ab5f11bae8-29149ef4:~# ping https://github.com/
ping: https://github.com/: Name or service not known
root@autodl-container-ab5f11bae8-29149ef4:~#
问题解决
如何正确使用 ping 命令?
应该从 URL 中移除 https:// 部分,并只使用域名。例如,要检查与 GitHub 的连接,应该使用以下命令:
ping github.com
这个命令将会发送 ICMP Echo 请求到 github.com 的服务器,并显示响应时间。