& Lt; Linux hostname command details & gt;

Source: Internet
Author: User
Tags nameserver

 

Tips for using the hostname command
We all know that the hostname command is used to view the Host Name and modify the host name.

 

[Root @ apache ~] # Hostname // view the Host Name of the Local Machine
Apache.example.com
[Root @ apache ~] # Hostname redhat // temporarily modify the Host Name
[Root @ apache ~] # Hostname
Redhat
[Root @ apache ~] # Uname-n // You can also display the Host Name
Redhat
However, such modifications are temporary. When your host is restarted, it will disappear immediately. to modify the changes, you must edit the configuration file:
# Vim/etc/sysconfig/network

 

Next let's take a look at other parameters of hostname:
[Root @ apache ~] # Hostname redhat.example.com
[Root @ apache ~] # Hostname-s // output the host name in short format
Redhat

 

[Root @ apache ~] # Hostname-a // display the host alias. If no output is blank

 

We all know that the ifconfig command is used to view the Host ip address. In fact, hostname can also view the Host ip address.
[Root @ apache ~] # Hostname-I // view the Host ip Address
192.168.1.113

 

[Root @ apache ~] # Hostname-d
Example.com

 

We all know how to view the configuration file by checking the Domain Name of the Local Machine:
[Root @ apache ~] # Cat/etc/resolv. conf
; Generated by/sbin/dhclient-script
Nameserver example.com
Nameserver 218.30.19.50
Nameserver 61.134.1.4
Of course, the hostname command is also awesome:
[Root @ apache ~] # Hostname-d // view the local domain name
Example.com

 

The following parameter is not commonly used.
[Root @ apache ~] # Hostname -- yp // check the NIS/YP domain name. It is not set to null.
(None)

 

 

 

 

 

 

 

 

 

Related Article

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.