Verifying Hostname Change
After temporarily changing the hostname using the hostname
command, you can verify the changes in several ways:
Checking the Hostname Command Output
You can directly check the current hostname by running the hostname
command:
$ hostname
new-hostname
This will display the updated temporary hostname.
Checking the /etc/hostname File
The /etc/hostname
file stores the system's permanent hostname. To verify the temporary hostname change, you can check the contents of this file:
$ cat /etc/hostname
myhost
Note that the contents of the /etc/hostname
file will still show the original hostname, as the temporary change is not reflected in this file.
You can also verify the hostname change by using network-related commands, such as hostname -f
(to display the fully qualified domain name) or hostname -i
(to display the system's IP address):
$ hostname -f
new-hostname.localdomain
$ hostname -i
192.168.1.100
These commands will display the updated temporary hostname in their output.
By using these methods, you can easily verify that the temporary hostname change has been applied successfully on your Linux system.