How to change the hostname in Linux (Redhat/Fedora/CentOS)

Source: Internet
Author: User

I found that the methods for changing the host's hostname in Linux are incomplete. The following is a complete method:

Step 00:

Assume that the original hostname is bkjia and you want to change it to bkjia03.

Use root to change the hostname

Su-rootStep 01:

Change bkjia in/etc/hosts to bkjia03

Vi/etc/hosts

:

127.0.0.1 bkjia03 localhost. localdomain localhostStep 02:

Change the HOSTNAME in/etc/sysconfig/network to bkjia03.

Vi/etc/sysconfig/network

NETWORKING = yes

HOSTNAME = bkjia03

GATEWAY = 61.67.71.126Step 03:

Use the hostname command again to specify

Hostname bkjia03 has been set. You can use the hostname command to confirm it once.

[Root @ bkjia etc] # hostname

Bkjia03

[Root @ bkjia etc] # If you log on again, the command prompt string will be changed to [root @ bkjia03 etc] #

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.