To find out the machine name or hostname of a Linux system, you can use the hostname
command. This command will display the current hostname of the system.
For example:
$ hostname mymachine
Alternatively, you can use the /etc/hostname
file to view the hostname. This file contains the hostname of the system, and it is used to set the hostname at boot time. To display the contents of this file, you can use the cat
command:
$ cat /etc/hostname mymachine
You can also use the uname
command with the -n
flag to display the hostname. This command displays various information about the system, including the hostname.
$ uname -n mymachine
Note that the hostname of a system may not always be the same as the domain name or the name that is used to access the system from other computers on the network. The hostname is a locally-configured name that is used to identify the system within the local network, while the domain name is a globally-unique name that is used to identify the system on the Internet.