LoginSignup
0
0

More than 1 year has passed since last update.

AWS AmazonLinux2 ホスト名の変更

Posted at

概要

  • AmazonLinux2の初期設定についてのまとめ
    • /etc/cloud/cloud.cfgの設定
    • hostnamectlによるホスト名の変更
      • /etc/hostnameの変更確認(念のため)

Amazon Linuxのホスト名の変更

// [preserve_hostname: true]の記載があるか確認
# cat /etc/cloud/cloud.cfg | grep preserve_hostname

// なければ末尾に追記
vi /etc/cloud/cloud.cfg
--------------------------
# host名設定
preserve_hostname: true
--------------------------

// 確認
# cat /etc/cloud/cloud.cfg | grep preserve_hostname
  • hostnamectlによるホスト名の変更
// 確認コマンド
# hostnamectl

// コマンドの実行&確認
# hostnamectl set-hostname hoge
# hostnamectl

// 設定反映のために再起動
# reboot
# hostnamectl

host名の変更方法

  • /etc/hostnameの変更
  • hostnamectlにて変更されるので不要(念のため確認するくらい)
// 確認
# cat /etc/hostname

// 変更&確認
# vi /etc/hostname
# cat /etc/hostname

// 設定反映のために再起動
# reboot

おまけ:RHEL7でのホスト名の状態

  • 6.1. ホスト名について
  • 以下の3つの状態があるとのこと
    • static (静的):/etc/hostname ファイルに保存される
    • pretty:ユーザーに自由形式の UTF8 ホスト名を提示
    • transient (一時的) :カーネルによって維持される動的なホスト名(リブート後staticに戻る)

参考

0
0
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
0
0