hostname Command: Tutorial & Examples
Display and change the hostname
hostname command is a command-line utility that allows you to view or set the hostname of a device running the Linux operating system.
By default, the hostname of a device is the name that is assigned to the device on the network. It is used to identify the device on the network and is typically set during the installation of the operating system.
You can use the
hostname command to view the current hostname of a device by running the following command:
You can also use the
hostname command to set the hostname of a device by running the following command:
new_hostname with the hostname you want to set for the device.
It's important to note that setting the hostname with the
hostname command is only a temporary change. If you want to make the hostname change permanent, you will need to modify
Here is an example of how to permanently set the hostname on a device running the Linux operating system:
echo "new_hostname" > /etc/hostname
This will set the hostname in the
/etc/hostname file, which is read by the operating system during boot up to set the hostname for the device.
CleverUptime uses the hostname to identify your server. Because it may not be unique, we also rely on other data such as the machine id.