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
[root@GitBucket-sv ~]# hostname
GitBucket-sv
[root@GitBucket-sv ~]#
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]
[root@GitBucket-sv ~]# hostname i
[Host name confirmation]
[root@GitBucket-sv ~]# hostname
i
[root@GitBucket-sv ~]#
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
[root@GitBucket-sv ~]# hostname -i
fe80::250:56ff:fe8c:2091%ens192 2404:7a80:91a1:4d00:250:56ff:fe8c:2091%2 192.168.0.150
[root@GitBucket-sv ~]#
** 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
[root@GitBucket-sv ~]# uname -n
GitBucket-sv
[root@GitBucket-sv ~]#
There is no problem if you make a mistake.
Example of incorrect input
[root@GitBucket-sv ~]# uname n
uname:Extra operator`n'
Try 'uname --help' for more information.
[root@GitBucket-sv ~]#
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