LoginSignup
246
234

More than 5 years have passed since last update.

CentOS 7 の Hostname を変更する

Last updated at Posted at 2014-07-12

概要

CentOS 7 の Hostname の変更方法です。

一時的に Hostname を変更する

bash
$ sudo hostname hogehoge.example.com
  • hostname コマンドで変更した場合再起動すると元に戻ります。

恒久的に Hostname を変更する (hostnamectl 使用)

(2017/4/23 コメントでアドバイスをいただいたので追記)

bash
$ sudo hostnamectl set-hostname <HOSTNAME>
  • 再起動不要
  • 一度セッションを抜けて再度ログインするとホスト名が変更されている

恒久的に Hostname を変更する (/etc/hostname を直接変更)

bash
$ sudo vim /etc/hostname
/etc/hostname
hogehoge.example.com
  • /etc/hostname のファイル内の値がそのまま Hostname に反映されます。
  • CentOS 6 とは編集するファイルが違うので要注意

参考URL

246
234
2

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
246
234