The difference between CentOS and Ubuntu modified hostname

Source: Internet
Author: User

    • CentOS Modify Host Name
1. Temporarily modify host name

Display host Name:

[Email protected]:~$ hostnamelocalhost

Modify Host Name:

[Email protected]:~$ sudo hostname orcl1[email protected]:~$ HOSTNAMEORCL1

2. Permanently modify the host name

The above modification is only a temporary change, after the restart is back to the original.

Step 1:

Modify the hostname in/etc/sysconfig/network

Vi/etc/sysconfig/networkhostname=localhost.localdomain  #修改localhost. Localdomain to ORCL1

Modify the hostname entry for the network. The point is preceded by the hostname, and the dot is followed by the domain name. No point is the host name.

This is permanently modified and takes effect after reboot.

To take effect immediately, you can execute the command at the same time:

Hostname ORCL1

Step 2:
Modify the/etc/hosts file

vi/etc/hosts127.0.0.1    localhost.localdomain  #修改localhost. Localdomain to ORCL1
Shutdown-r now    #最后, restart the server.
    • Ubuntu Modify host Name

1. Temporary modification
$sudo hostname Newhostname
After the reboot, it's back to the original.
2. Permanent modification

The first step:

sudo vi/etc/hostname

Step Two: Modify the Hosts file

Input: sudo vi/etc/hosts

Find the 127.0.1.1 line and change the old hostname on its right to your new host name. Restart Network
sudo/etc/init.d/networking restart
Or
Reboot
Restart the computer to take effect

The difference between CentOS and Ubuntu modified hostname

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.