How to permanently modify the hostname host name without rebooting under Ubuntu system

Source: Internet
Author: User

Just installed a Ubuntu operating system under VMware, opened the terminal and found that the host name of this long ah, the entire window is fully occupied.


To modify the hostname using hostname, run the command: "hostname new host name"

#hostname TEST-VM
This modification is only temporary, and the completion of the modification requires that the terminal window be reopened before changing.

And after the modification, the execution of the command will require a long time to wait, and the prompt cannot resolve the host


The Hosts file needs to be modified to modify the host name to native IP mappings.

To permanently modify the hostname you need to modify the file/etc/hostname

sudo vi/etc/hostname

The difference between/etc/hostname and/etc/hosts
/etc/hostname is a host name, an example of a hostname file:
Test-vm

/etc/hosts storage is the domain name and IP correspondence, the domain name and hostname do not have any relationship,
You can specify any one name for any IP, an example of a hostname file:
127.0.0.1 localhost
127.0.1.1 TEST-VM

after the modification is complete, use the service services to make hostname effective
sudo/etc/init.d/hostname.sh start
=========== Document Information ============
Copyright Disclaimer: Non-commercial free reprint-retain Attribution-Annotated source
Attribution (by): TESTCS_DN (micro-wx laughter)
article source: [Ignorant life, record bit] (HTTP://BLOG.CSDN.NET/TESTCS_DN)

How to permanently modify the hostname host name without rebooting under Ubuntu system

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.