Linux modify the host name! (Photo)

Benpian as a supplement to the previous articles, if you want to modify your host name, the teacher checks whether the job is convenient to do their own, can be used to modify the host name of the method, then how to modify it?

 

First, use the command hostname

For example, I now host name is haozhikuan-hbza, hbza-hbza can use the hostname hbza-hbza if I want to become a host name

Then hostname or uname -u can view their own host name, if we open a new terminal will be able to see their host name has been modified to become a hbza-hbza.

 

 But using the hostnamecommand can only be a temporary change our hostname, when we reboot the host name will be restored to the original

 

I want to permanently modify their own host name, available through the following steps

vi  /etc/hostname

Edit hbza-hbza is the new host name after restart you can see its own host name has been modified

 

 

 

 

 

Then I asked the next Baidu Can modify the host file, Baidu says so:

Change the host name is generally no need to modify the hosts file, / etc / hosts file to provide name resolution is a function of, like DNS, when the Linux system before issuing domain name resolution request to the DNS server will query the / etc / hosts file, if there are corresponding record, which hosts will use the recording

So you want to modify the host name, then modify / etc / sysconfig / network file on the line, but if you want to use a distributed, host name and ip need to be bound together, only need to modify the hosts file

 

Guess you like

Origin www.cnblogs.com/hzk001/p/11713917.html