Hostname and Linuxhostname in Linux

Source: Internet
Author: User

Hostname and Linuxhostname in Linux
Hostname command to view the host's hostname,
# Hostname
The hostname command can be used to set the system's hostname.
# Hostname newname
Newname is the new hostname to be set. It takes effect immediately after running (restart shell), but changes will be lost after the system is restarted. If you want to change the hostname of the system permanently, modify the configuration file.

Modify the hostname in the/etc/sysconfig/network file and change the line HOSTNAME to HOSTNAME = NEWNAME. NEWNAME is the hostname you want to set.
The configuration file of the Debian release hostname is/etc/hostname.
After the configuration file is repaired, the system restarts and reads the configuration file to set a new hostname.

Relationship between hostname and/etc/hosts
When talking about changing the hostname, many people first think of modifying the/etc/hosts file and think that the hostname configuration file is/etc/hosts. Actually not.
The hosts file acts like DNS and provides the corresponding IP address to the hostname. There were few computers on the Internet in the early days, and the hosts file on a single machine was enough to store all the computers on the Internet. However, with the development of the Internet, this is far from enough. As a result, a distributed DNS system emerged. The DNS server provides a similar IP address to the corresponding domain name. Man hosts is supported.
The Linux system will query the/etc/hosts file before sending a domain name resolution request to the DNS server. If there is a corresponding record in it, the record in hosts will be used.

After the hostname is modified, if you want to access the host with newhostname, you must add a newhostname record in the/etc/hosts file.
For example:
# Hostname server1.localdomain

# Cat/etc/hosts
127.0.0.1 localhost. localdomain localhost
192.168.2.5 server1.localdomain
In this way, I can access the local machine through server1 or server1.localdomain.

At the same time, you must note that 192.168.2.5 must be accessible. Otherwise, it will take a long time to start the starting sendmai step.


How to change the Linux hostname

# Vi/etc/hosts
111.111.111.111 hostname
# Vi/etc/sysconfig/network
Modify HOSTNAME = hostname
# Service network restart

The listener may be incorrect. After listener. ora
Netca deletes the LISTENER and creates a new LISTENER.

What is the host name in LINUX?

Name of the machine. If the name is UCHS-HB3G-CLPS-02, it is displayed after the root remote SSH Login
[Root @ UCHS-HB3G-CLPS-02 ~] #
Mode. You can visually distinguish the machines and users currently operated.

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.