LoginSignup
106

More than 5 years have passed since last update.

posted at

updated at

sudo: unable to resolve host が表示されたら

sudo: unable to resolve hostが表示されたら、/etc/hostsにホスト名を追加します。

手順

まずは、/etc/hostsを確認します。

sudo: unable to resolve hostが表示されています。

$ sudo cat /etc/hosts
sudo: unable to resolve host foobar
127.0.0.1       localhost
127.0.1.1       hostname.domainname hostname

/etc/hostsにホスト名を追加します

$ sudo sh -c 'echo 127.0.1.1 $(hostname) >> /etc/hosts'

もう一度、/etc/hostsを確認します。

ホスト名が追加されたので、sudo: unable to resolve hostが表示されません。

$ sudo cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       hostname.domainname hostname
127.0.1.1 foobar

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
106