Get the App
SLTechnology News&Howtos  ›  Servers  › 

Use the hostname command of linux to display and set the hostname of the system

Shulou Source: shulou.com Published: 2022-06-02 12:44:11 09月30日 Update

This article mainly introduces the use of linux hostname command to display and set the hostname of the system, the article is very detailed, has a certain reference value, interested friends must read it!

The hostname command displays and sets the hostname of the system. The environment variable HOSTNAME also holds the current hostname.

After the hostname is set with the hostname command, the system does not permanently save the new hostname, but the original hostname after restarting the machine. If you need to permanently change the hostname, you need to modify both / etc/hosts and / etc/sysconfig/network.

Syntax format: hostname [parameters]

Common parameters:

-a display host alias-d display DNS domain name-f display FQDN name-I display host ip address-s display short host name, truncate-y display NIS domain name at the first point

Reference example

Use the-a parameter to display the host alias:

[root@linuxcool] # hostname-a

Use the-I parameter to display the ip address of the host:

[root@linuxcool] # hostname-I

Use the-y parameter to display the NIS domain name:

[root@linuxcool ~] # hostname-y above is all the contents of displaying and setting the hostname of the system using the hostname command of linux. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Host parameter command system content name domain name alias address permanent reference value interest variable at the same time instance buddy buddy commonly used more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS Apple Shulou Information MariaDB