微信关注,获取更多

Linux下hostname命令的用法详解

  Linux中的hostname命令主要用于显示及设置系统的主机名称,如果你想要修改主机名称的话,使用该命令是最好不过的了,下面随小编一起来学习下吧。

 Linux下hostname命令的用法详解

  我们直接运行hostname可以查看目前的主机名称,要查看hostname的其它命令参数,运行hostname -h如下:

  代码如下:

  Usage: hostname [-v] {hostname|-F file} set hostname (from file)

  domainname [-v] {nisdomain|-F file} set NIS domainname (from file)

  hostname [-v] [-d|-f|-s|-a|-i|-y|-n] display formatted name

  hostname [-v] display hostname《/p》 《p》hostname -V|–version|-h|–help print info and exit《/p》 《p》dnsdomainname=hostname -d, {yp,nis,}domainname=hostname -y《/p》 《p》-s, –short short host name

  -a, –alias alias names

  -i, –ip-address addresses for the hostname

  -f, –fqdn, –long long host name (FQDN)

  -d, –domain DNS domain name

  -y, –yp, –nis NIS/YP domainname

  -F, –file read hostname or NIS domainname from given file《/p》 《p》This command can read or set the hostname or the NIS domainname. You can

  also read the DNS domain or the FQDN (fully qualified domain name)。

  Unless you are using bind or NIS for host lookups you can change the

  FQDN (Fully Qualified Domain Name) and the DNS domain name (which is

  part of the FQDN) in the /etc/hosts file.

  看到-v的用法了吗?修改主机名命令如下:

  代码如下:

  hostname -v 新的主机名

  上面就是Linux下使用hostname命令修改主机名称的方法介绍了,先使用该命令查看Linux主机,然后在组合参数进行主机名称修改,是不是很方便呢,赶紧试试看吧。

未经允许不得转载:系统吧-电脑系统大神 » Linux下hostname命令的用法详解

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏