Querying and modifying host information
I. How to modify the Linux host name
1. Change the current host name
1.1 echo New-hostname>/proc/sys/kernel/hostname (when the system starts, the host name is read from this file)
1.2 hostname New-hostname (effective immediately, but will expire after the system is restarted)
2. modify the configuration file so that the new host name is used at the next restart.
2.1 edit the file:/etc/sysconfig/Network
2.2 modify: Hostname = new-hostname.domainname
By modifying the hostname in the/etc/sysconfig/network file, you can set a new host name. Of course, you need to reactivate the host to take effect; next, modify the/etc/hosts file. Next, describe the file content in hosts. The content is as follows:
127.0.0.1 localhost. localdomain localhost (IPv4)
: 1 localhost. localdomain localhost6 (IPv6)
3. Configure the local domain name resolution file so that the local application can resolve the new host name
3.1 edit the file:/etc/hosts
Modify: XXX. XXX new-hostname.domainname New-hostname (here XXX represents the local network
Network Address, which can also be the loopback address 127.0.0.1 ).
4. Modify through the graphic interface
Run the neat command to open the following interface (be familiar with it)
Note: The/etc/hosts file is mainly for parsing. hosts is only used to explain the host in the network and the corresponding IP Address File for querying the host of the hosts owner; therefore, you can directly modify the network file to modify the host name. Of course, you should also modify the hosts document. Of course, you only need to modify the network document, which will take effect after restart.
Ii. How to view Host IP information
1. Use the hostname command to obtain host and IP information
Hostname-A: Get the host alias.
Hostname-D: Obtain the DNS domain name.
Hostname-F: Get the FQDN name.
Hostname-I: Obtain the IP address of the host.
Hostname-S: Get the NetBIOS Name of the domain name.
2. ifconfig
Ifconfig: view all network interface information (including other information, such as IP address, MAC address, and MTU value)
Ifconfig-Interface: view the specified interface information (including IP information)
For reprint, please indicate the source and original article links:
Http://blog.csdn.net/xiangsir/article/details/8570427