Linux host name Modification

Source: Internet
Author: User

Linux host name Modification
GuideIn a LAN, each machine has a host name, which facilitates the distinction between the host and the host. Therefore, you can set a host name for each machine to access each other easily. For example, we can name each machine based on its functions in the LAN.

View host name commands
[root@tonyx ~]# uname -ntonyx[root@tonyx ~]# hostnametonyx
Use the hostname command

Command Format: hostname newhostname
Modify the host name temporarily, log out with the logout command, and log on again to take effect. But it does not take effect permanently.

Modify through the configuration file/etc/sysconfig/network

Modify the configuration file. The linux host name will take effect after the next restart. If the configuration file takes effect permanently, use the hostname command.

[root@tonyx ~]# cat /etc/sysconfig/networkNETWORKING=yesHOSTNAME=tonyxu
File/etc/hosts Functions

A row of this file corresponds to a comparison. The format of each row is:
The alias of the ip global host name.
This section compares ip addresses and host names ., You can associate some common website domain names with their corresponding IP addresses to a database, the system will first automatically find the corresponding IP address from the Hosts file. Once found, the system will immediately open the corresponding webpage, which is equivalent to DNS resolution.
For example, if the ip address of baidu is 220.181.57.217, you can add a line at the end of the file:

[root@tonyx ~]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6220.181.57.217 baidu.com

Address: http://www.linuxprobe.com/

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.