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)