I would like to write about the reason why I basically do not use the "hostname" command because I have experience from Linux operation monitoring to design and construction.
Linux OS in general (RHEL / CentOS / Solaris, etc.)
This command confirms the host name of the Linux OS.
The usage is like this.
hostname
[[email protected]GitBucket-sv ~]# hostname
GitBucket-sv
[[email protected] ~]#
In this way, it is a command that can confirm the host name.
For details, please see the explanation on this site. [Hostage] command-display / set the host name
** This is because the host name may be changed due to incorrect input. ** **
Here is an example of incorrect input.
typo
[Command input]
[[email protected] ~]# hostname i
[Host name confirmation]
[[email protected] ~]# hostname
i
[[email protected] ~]#
In this way, the host name itself will change. (In the above case, the host name is "i".)
By the way, hostname -i
is a command to check the IP address of the server.
IP address confirmation
[[email protected] ~]# hostname -i
fe80::250:56ff:fe8c:2091%ens192 2404:7a80:91a1:4d00:250:56ff:fe8c:2091%2 192.168.0.150
[[email protected] ~]#
** In this way, it is possible to change the host name due to incorrect input, so basically it is not recommended to use it. ** **
The ʻuname -n` command is recommended.
Here is an example of execution.
Execution example
[[email protected] ~]# uname -n
GitBucket-sv
[[email protected] ~]#
There is no problem if you make a mistake.
Example of incorrect input
[[email protected] ~]# uname n
uname:Extra operator`n'
Try 'uname --help' for more information.
[[email protected] ~]#
As you can see, the error is displayed.
If you want to know more about the ʻuname` command, please see the explanation on this site. uname command (displays OS or hardware information)
It is safe to refrain from using the hostname
command when checking the host name.
→ There is a possibility that the host name will be changed by mistake.
When checking the host name, it is safer to check with the ʻuname -n` command. → There is no risk of changing the host name
Recommended Posts