How do I modify the CentOS server host name?

Source: Internet
Author: User
Keywords Server CentOS host name
Tags centos default etc host host name hostname hosts how to

CentOS Server installed, the default host name is: Localhost.localdomain, in order to and management, we need to modify the server host name, this modification takes effect on two profiles/etc/sysconfig/network and etc /hosts, here's how to do it:

[Root@localhost ~]# Vi/etc/sysconfig/network
Networking=yes
Hostname=localhost.localdomain
gateway=192.168.1.1

Modified to:

[Root@localhost ~]# Cat/etc/sysconfig/network
Networking=yes
Hostname=ithov.com&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP; #此处HOSTNAME即为你需要修改的主机名
gateway=192.168.1.1


[Root@localhost ~]# vi/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6

After we open the Hosts file, we modify it,

Where 127.0.0.1 is the local loop address, Localhost.localdomain is the host name (hostname), which is what you want to modify. LocalHost is the alias of the host name (alias), which appears under the Konsole prompt. Change the second item to your host name and the third option.

[Root@localhost ~]# cat/etc/hosts
127.0.0.1 localhost ithov.com localhost4 localhost4.localdomain4
:: 1 localhost ithov.com localhost6 localhost6.localdomain6


Restart the computer to take effect
[Root@localhost ~]# reboot

The host name has been modified successfully after landing:

Last login:wed June 4 23:51:33 2014 from 192.168.1.3
[Root@ithov ~]#

[Root@ithov ~]# Uname-n
Ithov.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.