当前位置:网站首页>The return values of hostname -f and uname -n may be different
The return values of hostname -f and uname -n may be different
2022-06-29 08:38:00 【Migrant worker Lao Wang】
Blog home page :https://tomcat.blog.csdn.net
Blogger's nickname : Lao Wang of migrant workers
Main areas :Java、Linux、K8S
We look forward to your attention, praise and collection comments
Catalog
At work , Due to the operation requirements of the software used , I met Linux Most systems will set the host name to something like test.laowang.cn Such a fully qualified domain name . In contact with Linux At the beginning of the , I learned through the Internet , The command to get the fully qualified domain name is hostname -f , And when writing scripts , Use this command frequently . And then , I took over what other colleagues wrote shell Script , Read uname -n This order . This command is the first time I have seen , After checking its general function on the Internet , Then run this command on the computer , The fully qualified domain name is also found . then , I thought hostname -f And uname -n The return value of , It's the same , All are Linux The fully qualified domain name of the system .
The return value is the same
In general , If in /etc/hostname and /etc/hosts The same host name is written in , that hostname -f And uname -n The return value of is the same , As shown in the figure below :

When the return value is different
Only later , The return values of these two commands are likely to be different . If you will /etc/hostname The value in is set to a single word that is not separated by a dot . meanwhile , stay /etc/hosts in , For this machine ip Set two machine names , And only the shorter one is related to /etc/hostname Consistent values for , You can make hostname -f And uname -n The return value of is different . As shown in the figure below :
Compare hostname and uname command
By looking at the help of the two commands , I can see hostname It is mainly used to view or set the host name -f The parameter indicates the fully qualified domain name ,-s Parameter represents short name . and uname The full English name of the command is “Unix name”, Used to display system related information , For example, host name 、 Kernel version number 、 Hardware architecture, etc ,-n Indicates the name of the output local network node .
Current operations show that ,hostname -f And uname -n The return value of may be different ,hostname -s And uname -n The return value of is generally the same . But I can't tell hostname -s And uname -n It's two equivalent commands , So when we program , It's best not to be in a program , Alternate the two commands to get the hostname .


If you want to reprint , Please indicate the source of this article : Migrant worker Lao Wang's CSDN Blog https://blog.csdn.net/monarch91 .
边栏推荐
- 想炒股开户,在网上进行股票开户安全吗?-
- 互斥量互斥锁
- 【LoRaWAN节点应用】安信可Ra-08/Ra-08H模组入网LoRaWAN网络的应用及功耗情况
- How to recite words in tables
- NP3 格式化输出(一)
- Notes on key words in the original English work biography of jobs (VII) [chapter five]
- Hook 簡介
- 《乔布斯传》英文原著重点词汇笔记(八)【 chapter six 】
- Summary of various series (harmonic, geometric)
- Chengtong network disk imitation blue playing network disk source code with video tutorial
猜你喜欢
随机推荐
人民链鲍大伟:打破壁垒,建立全域数据治理共享及应用平台
Using method and de duplication of distinct() in laravel
考研英语易混词整理【闪过】
Set up Jenkins environment and automatically associate packaged project jars for automatic release
目标跟踪【单目标跟踪(VOT/SOT)、目标检测(detection)、行人重识别(Re-ID)】
Actual combat memoir starts from webshell to break through the border
NP3 格式化输出(一)
背包九讲——全篇详细理解与代码实现
dcase_ Util tutorial
In PHP version 7.1.13, it is found that floating-point data passes through JSON during use_ There will be precision problems after encode
js for in循环 for of循环的区别以及用法
Explain the garbage collection mechanism (GC) in JVM
Development trend of garment industry | supply chain | intelligent manufacturing
实战回忆录:从Webshell开始突破边界
马赛克笔记
How to recover data loss of USB flash disk memory card
开户买基金,通过网上基金开户安全吗?-
【微服务|OpenFeign】openfeign的超时时间
Message Oriented Middleware: pulsar
Automatic operation and maintenance management platform - construction and daily use of SPuG










