How to read the hostname in Ubuntu?


I want to know the hostname of the VM I have created in AWS. Which command I can use to get the hostname?

1 Answer

4 years ago by

hostnamectl is the command you are looking for.
Following is example output.

ubuntu@ip-xxx-xx-x-xxx:~$ hostnamectl
   Static hostname: ip-xxx-xx-x-xxx
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 4c1494be4d2a87817ee86cd18795b458
           Boot ID: 79d342a93ae812e2c0ba4b3a9221c533
    Virtualization: xen
  Operating System: Ubuntu 16.04.2 LTS
            Kernel: Linux 4
4 years ago by Karthik Divi