sudo 出現unable to resolve host 解決方案

來源:互聯網
上載者:User

Ubuntu環境, 假設這台機器名字叫abc(機器的hostname), 每次執行sudo 就出現這個警告訊息:
sudo: unable to resolve host abc
雖然sudo 還是可以正常執行, 但是警告訊息每次都出來,而這隻是機器在反解上的問題, 所以就直接從/etc/hosts 設定, 讓abc(hostname) 可以解回127.0.0.1 的IP 即可.

/etc/hosts 原始內容

          127.0.0.1       localhost

          # The following lines are desirable for IPv6 capable hosts 

          ::1     localhost ip6-localhost ip6-loopback ip6-loopback

         fe00::0 ip6-localnet 
         ff00::0 ip6-mcastprefix 
         ff02::1 ip6-allnodes
         ff02::2 ip6-allrouters 

         ff02::3 ip6-allhosts  

         在127.0.0.1 localhost 後面加上主機名稱(hostname) 即可, /etc/hosts 內容修改成如下:

127.0.0.1       localhost abc  #要保證這個名字與 /etc/hostname中的主機名稱一致才有效
# 或改成下面這兩行 
#127.0.0.1       localhost 

#127.0.0.1       abc

這樣設完後, 使用sudo 就不會再有那個提示資訊了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.