Modify Ubuntu host Name

Source: Internet
Author: User

1. What is Ubuntu host name

When you log in to Ubuntu after you export your account password, you will see a line prompt

[email protected]~$

The ' Wang ' before the ' @ ' sign is your account name; After the ' @ ' sign, ': ' Before ' Ubuntu ' is the hostname

Use the hostname command to view the host name

[Email protected]:~$ hostname

Ubuntu

2. Temporarily modify host name

Use the hostname command to temporarily modify the hostname and fail after reboot

[Email protected]:~$ sudo hostname UBUNTU

[sudo] password for Wang:

[Email protected]:~$ hostname

Ubuntu

You will find that the host name viewed with hostname has been changed from "Ubuntu" to "Ubuntu" in uppercase. However, the host name in the prompt does not change, use the Exit command to exit the current account, and then log back in, and you will find

[email protected]: ~$

The host name in this prompt has been "UBUNTU" in uppercase

When you restart the computer, you will find the prompt back to the lowercase ' ubuntu ', using the hostname command to view the host name when the actual is also lowercase ' ubuntu '

[Email protected]:~$ hostname

Ubuntu

3. Permanently modify the host name

You need to modify the '/etc/hostname ' and '/etc/hosts ' files if you want to modify the host name to take effect permanently

Check out these two files with the cat command first

[Email protected]:~$ cat/etc/hostname

Ubuntu

[Email protected]:~$ cat/etc/hosts

127.0.0.1 localhost

127.0.1.1 Ubuntu

# The following lines is desirable for IPV6 capable hosts

:: 1 localhost ip6-localhost ip6-loopback

Ff02::1 Ip6-allnodes

Ff02::2 ip6-allrouters

Only the host name is saved in the '/etc/hostname ' file; the second line in the '/etc/hosts ' file is followed by the hostname. After the two host names are modified, restart the computer to complete a permanent modification of the host name.

Use the VIM command to modify the '/etc/hostname ' and '/etc/hosts ' files

[Email protected]:~$ sudo vim/etc/hostname

[Email protected]:~$ sudo vim/etc/hosts

The modified file should look like this, using the cat command to view

[Email protected]:~$ cat/etc/hostname

Ubuntu

[Email protected]:~$ cat/etc/hosts

127.0.0.1 localhost

127.0.1.1 UBUNTU

# The following lines is desirable for IPV6 capable hosts

:: 1 localhost ip6-localhost ip6-loopback

Ff02::1 Ip6-allnodes

Ff02::2 ip6-allrouters

Restart the computer at this point, you can find that the host name in the prompt has become uppercase ' Ubuntu ', using the hostname command to view the host name has also become uppercase ' Ubuntu '

Modified successfully:)

Modify Ubuntu host Name

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.