How To Get Host Name and Domain Name Of Linux?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/get-host-name-domain-name-of-linux/
PINTEREST
PINTEREST
INSTAGRAM

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

Host name information is stored in a file /etc/hostname . So we can simple print the host name to the terminal with echo command like below.

Get Host name By Echoing Host name File
Get Host name By Echoing Host name File

Get Host name With hostname Command

We can get host name with hostname command. This will only list host name and will not print domain related information.

Get Host name With host name Command
Get Host name With host name Command

Get Fully Qualified Host name

We can get fully qualified host name which provides full name with domain information.

Get Fully Qualified Host name
Get Fully Qualified Host name

Hostname File

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

As the hostname is stored in the /etc/hostname file we can change the hostname by editing this file. We will set the hostname as ubu1 with the following echo command. Keep in mind that in order to change /etc/hostname file we require root privileges which can be get with the sudo command.

Change Hostname
Change Hostname

Get Domain Name

Domain name information is about the systems network configuration.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/get-host-name-domain-name-of-linux/
PINTEREST
PINTEREST
INSTAGRAM
LEARN MORE  Windows Netstat Command Tutorial with Examples To List Network Ports and Connections