Host name is the identifier of a system in the network. Host name can be get with different ways in Linux. Host name is generally put in the /etc/hostname file.
Get Host name By Echoing Host name File
We can echo host name file and get the host name very simple manner.
$ cat /etc/hostname
Get Host name With host name Command
We can get host name with host name command. This will only list host name and will not print domain related information.
Get Fully Qualified Host name
We can get fully qualified host name which provides full name with domain information.
$ hostname -f
Host name file /etc/hostname will only provide host name with fully qualified domain name. There will any no other data in this file.
Change Host name
Changing host name is easy as getting it. We will add new host name to the host name file with root privileges.
$ echo "ubu1" > /etc/hostname
Get Domain Name
Domain name information is about the systems network configuration.