Each person has a unique identity, such as their name and birth date. Computers also have individual identities, specifically, their hostnames and internet protocol (IP) addresses. Each machine has a valid IP address, but referring to a system by its IP address is not practical.
Instead, you can configure a computer's hostname, which is the machine's human-friendly name. You can map the hostname to the IP address so that it's easy to connect to a machine using its name.
[ Download now: Advanced Linux commands cheat sheet. ]
Configure a static hostname
Display the system's hostname using:
$ hostname
You can also use the hostname
command to modify the system's name temporarily. Here's an example:
$ hostname demo.example.com
![hostname configuration commands](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2022-08/Picture1.png.webp?itok=vOpy6Aj1)
This change is only temporary. After a reboot, all changes will revert.
Configure a persistent hostname
To persistently change the hostname, use the hostnamectl
command, or directly modify the default configuration file /etc/hostname
.
[ Learn how to manage your Linux environment for success. ]
Here's an example of modifying the hostname permanently using the hostnamectl
command. This shows the change:
$ hostnamectl set-hostname server1.example.com
![hostnamectl commands](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2022-08/picture2.png.webp?itok=91DVYHSK)
After executing this command, don't forget to verify the change using the hostname
command.
You can confirm this entry by displaying the /etc/hostname
file contents.
Wrap up
These examples show you how to configure the hostname for your machine. Note that during the configuration steps, your system will not automatically resolve the hostname with the IP address. This article covers only how to configure the hostname for a machine.
執筆者紹介
Shiwani Biradar is an Associate Technical support Engineer in Red Hat. She loves contributing to open source projects and communities. Shiwani never stops exploring new technologies. If you don't find her exploring technologies then you will find her exploring food. She is familiar with Linux, Cloud, and DevOps tools and enjoys technical writing, watching TV series, and spending time with family.
類似検索
チャンネル別に見る
自動化
テクノロジー、チームおよび環境に関する IT 自動化の最新情報
AI (人工知能)
お客様が AI ワークロードをどこでも自由に実行することを可能にするプラットフォームについてのアップデート
オープン・ハイブリッドクラウド
ハイブリッドクラウドで柔軟に未来を築く方法をご確認ください。
セキュリティ
環境やテクノロジー全体に及ぶリスクを軽減する方法に関する最新情報
エッジコンピューティング
エッジでの運用を単純化するプラットフォームのアップデート
インフラストラクチャ
世界有数のエンタープライズ向け Linux プラットフォームの最新情報
アプリケーション
アプリケーションの最も困難な課題に対する Red Hat ソリューションの詳細
オリジナル番組
エンタープライズ向けテクノロジーのメーカーやリーダーによるストーリー
製品
ツール
試用、購入、販売
コミュニケーション
Red Hat について
エンタープライズ・オープンソース・ソリューションのプロバイダーとして世界をリードする Red Hat は、Linux、クラウド、コンテナ、Kubernetes などのテクノロジーを提供しています。Red Hat は強化されたソリューションを提供し、コアデータセンターからネットワークエッジまで、企業が複数のプラットフォームおよび環境間で容易に運用できるようにしています。
言語を選択してください
Red Hat legal and privacy links
- Red Hat について
- 採用情報
- イベント
- 各国のオフィス
- Red Hat へのお問い合わせ
- Red Hat ブログ
- ダイバーシティ、エクイティ、およびインクルージョン
- Cool Stuff Store
- Red Hat Summit