uTools-Manuals/docs/linux/hostname.html
2019-04-21 11:50:48 +08:00

26 lines
1.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="hostname">hostname</h1>
<p>显示和设置系统的主机名</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>hostname命令</strong> 用于显示和设置系统的主机名称。环境变量HOSTNAME也保存了当前的主机名。在使用hostname命令设置主机名后系统并不会永久保存新的主机名重新启动机器之后还是原来的主机名。如果需要永久修改主机名需要同时修改<code>/etc/hosts</code><code>/etc/sysconfig/network</code>的相关内容。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">hostname(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-v详细信息模式
-a显示主机别名
-d显示DNS域名
-f显示FQDN名称
-i显示主机的ip地址
-s显示短主机名称在第一个点处截断
-y显示NIS域名。</code></pre>
<h3 id="参数">参数</h3>
<p>主机名:指定要设置的主机名。</p>
<h3 id="实例">实例</h3>
<pre><code class="language-bash">[root@AY1307311912260196fcZ ~]# hostname
AY1307311912260196fcZ
# change hostname
hostname newname # for now
vi /etc/hosts # forever
reboot</code></pre>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->