Linux common commands-26: hostname

The hostname command is used to display and set the hostname of the system. The environment variable HOSTNAME also holds the current hostname. However, after using the hostname command to set the host name, the original host name is still used after the system restarts. If you need to make permanent changes, you need to modify the files /etc/hostname and /etc/hosts at the same time.

Syntax format: hostname [parameter]

Common parameters:

Example

 # 显示主机名hostname # 显示主机的ip地址hostname -i # 修改主机名为test hostname test

This article is reprinted from https://xugaoxiang.com/2022/06/07/linux-cmds-26-hostname/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment