歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> linux hostname的配置方法

linux hostname的配置方法

日期:2017/3/3 12:03:27   编辑:Linux技術

1.簡介

hostname 用於顯示系統的主機名稱,可以設置。

它的修改方法很簡單,但是稍不注意,又會惹出一大堆的麻煩和困惑。

2.配置方法

步驟1:使用命令修改:

hostname 新的名稱注意:此命令可以即刻修改hostname,但是系統重啟後失效。

步驟2:修改配置文件

第1步操作完畢後,為了保證重啟後依然有效,需要修改相應的配置文件,使用命令:

vim /etc/sysconfig/network修改HOSTNAME對應的值:

然後保存,退出即可。

系統啟動的時候會讀取hostname的值,具體是讀什麼配置文件,可以參考一下官方文檔的說法。

首先 man hostname,看如下這一段:

具體的原因,我不翻譯了。簡要來說,/etc/sysconfig/network 與 /etc/hosts 的配置不沖突(即hostname是相同的),是不會出問題的。再請注意一下,/etc/hosts 相當於是 DNS,這一點不要搞混淆了,它和修改 hostname 沒有

直接關系。

本文內容參考如下:

【1】http://soft.chinabyte.com/os/281/11563281.shtml

注意:

如您發現本文檔中有明顯錯誤的地方,

或者您發現本文檔中引用了他人的資料而未進行說明時,請聯系我進行更正。

轉載或使用本文檔時,請作醒目說明。

必要時請聯系作者,否則將追究相應的法律責任。

note:

If you find this document with any error ,

Or if you find any illegal citations , please contact me correct.

Reprint or use of this document,Please explain for striking.

Please contact the author if necessary, or they will pursue the corresponding legal responsibility.

Copyright © Linux教程網 All Rights Reserved