Modify hostname in CentOS/RedHat

Source: Internet
Author: User

Step 1:

# Su-root (or log on as the root user)

Otherwise, the hostname cannot be modified.

We can view the name of the current hostname:

[Root @ vm1035 ~] # Hostname
Vm1035
[Root @ vm1035 ~] #

Then we change vm1035 to vm3012.

 

Step 2:

# Vi/etc/hosts

Change the vm1035 output in/etc/hosts to vm3012, for example:

# Do not remove the following line, or various programs
# That require network functionality will fail.
127.0.0.1 melvrhel5tmp localhost. localdomain localhost
: 1 localhost6.localdomain6 localhost6
10.30.149.35 vm3012.autotest. corp vm3012

 

Step 3:

# Vi/etc/sysconfig/network

Change the hostname to vm3012 as follows:

 

NETWORKING = yes
NETWORKING_IPV6 = yes
HOSTNAME = vm3012

 

 

Step 4:

# Hostname vm3012

Use the command to specify the hostname.

 

Step 5:

Once you log on again, the command prompt character will change:

[Root @ vm3012 ~] #

 

It indicates that the hostname is successfully modified. ^_^

 

 

 

Related Article

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.