Ubuntu How to modify the host name of the terminal terminal (Modify/etc/hostname file)

Source: Internet
Author: User
Tags cloud vps

Sometimes after installing Ubuntu system, open the command terminal, terminal display of the host name format is ugly, such as I recently bought a cloud VPS in the country. [Plain]View PlainCopy
    1. [Email protected]$
    2. [Email protected]$
For the people who are neat and tidy, see so long also with the system name of the crossbar is annoying, want to go into various ways to eliminate him, fortunately, the command modification on Linux is particularly convenient.
I. About the hostname commandThe hostname command allows you to view and set the name of the current system on Linux 1. View hostname [Plain]View PlainCopy
    1. [Email protected]$ hostname
    2. Vm-1560-ubuntu
2. Set hostname [Plain]View PlainCopy
    1. [Email protected]$ hostname newhostname
    2. Hostname:you must is root to change the host name
This is because modifying the hostname changes the system properties and requires root privileges. [Plain]View PlainCopy
    1. [Email protected]$ sudo hostname newhostname
Can.
Ii. about/etc/hostname documentsThis file stores the name of the hostname, which gets the name of the system each time it is started by reading the file. Iii. about/etc/hostsNetwork host name, you can redirect the IP that the domain name points to by modifying the Hosts file. Before this method can be viewed outside the colorful, as if these two years, haha, you understand. [Plain]View PlainCopy
    1. [Email protected]$ sudo vim/etc/hosts
    2. 127.0.0.1 localhost Vm-1560-ubuntu
127.0.0.1 is the IP of this machine. Iv. modifying host names1. hostname Modify the system name [Plain]View PlainCopy
    1. [Email protected]$ hostname newhostname
2. Modify the/etc/hostname file [Plain]View PlainCopy
    1. [Email protected]$ sudo vim/etc/hostname
Change Vm-1560-ubuntu to Newhostname3. Modify the/etc/hosts file [Plain]View PlainCopy
    1. [Email protected]$ sudo vim/etc/hosts
Modified before 127.0.0.1 localhost Vm-1560-ubuntu modified 127.0.0.1 localhost newhostname4. Open a new terminal, the system name of the terminal window has been modified [Plain]View PlainCopy
    1. [Email protected]$
This method is suitable for Ubuntu systems, such as Ubuntu16.04,ubuntu 16.10. http://blog.csdn.net/sweettool/article/details/70963198

Ubuntu How to modify the host name of the terminal terminal (Modify/etc/hostname file)

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.