LoginSignup
4
2

More than 1 year has passed since last update.

mac のターミナルで hosts ファイルを書き換える方法

Last updated at Posted at 2022-06-21

はじめに

mac で hosts ファイルを書き換える方法です。
mac のターミナルでも iterm2 でもなんでも問題ないです!

hosts ファイル書き換え

以下のコマンドを実行します。

$ sudo vi /etc/hosts

すると、

Password:

と出るので、お使いの PC のパスワードを入力します。
以下のような画面が出てきます。

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##

こちらを編集するために、「i」とキーボードで打つと INSERT モードに切り替わり編集できます。
IP アドレス + 半角スペース + ホスト名を入力します。

111.111.111 example.com

入力したら、「esc」ボタンを入力し、INSERT モード終了。

保存する場合は

:wq

やっぱり辞める場合は

:q

強制終了

:!q
4
2
0

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
  3. You can use dark theme
What you can do with signing up
4
2