Of course, let's put what we know about understanding in Ubuntu Linux hostname
into list form:
Reference:
https://www.howtouseubuntu.com/network/change-hostname-in-ubuntu-linux/
-
Definition :
hostname
is a command in Ubuntu (and other Linux distributions) that displays the hostname of the system. A hostname is the name by which a system is recognized by other systems on the network. It is also used by system messages and applications. -
Check your hostname : To check your current hostname, just type in terminal
hostname
and hit enter. It will output the current hostname of the system.$ hostname myhostname
-
Temporarily change hostname : To temporarily change the hostname (which will reset to the original hostname after a system reboot), use
hostname
followed by the new name:$ sudo hostname newhostname
will be
newhostname
replaced with your desired hostname. -
Changing the hostname permanently : To change the hostname permanently, an edit
/etc/hostname
and/etc/hosts
a file are required. Replace the current hostname with the new hostname in these files. It is recommended to run bothsudo hostname newhostname
to change the hostname currently in use so you don't have to reboot. -
Hostname file :
/etc/hostname
The file contains the hostname of the system. It is only one line, containing the hostname of the system. -
Hosts file :
/etc/hosts
A file that maps hostnames to IP addresses. Your system hostname should have an entry in this file. -
Hostname and Networking : Your system hostname is used by networking systems to identify your machine. This is especially important when dealing with network protocols.
-
Fully Qualified Domain Name (FQDN) : The command with
-f
optionhostname
displays the fully qualified domain name (FQDN) of the system.$ hostname -f myhostname.domain.com
-
Hostnames and applications : Some applications use hostnames to generate paths and identifiers. Changing the hostname while these applications are running may cause errors.
-
System Security : Changing the hostname can also be used as a minimal security measure to prevent attackers from easily identifying your system operating system and structure.
Understanding hostname
commands and how they work in Ubuntu Linux can help you manage your system more efficiently, especially in a networked environment.
We have compiled a pdf file of Linux learning, put it in the following path, you can mention it yourself:
https://www.howtouselinux.com/post/linux-commands-for-linux-beginners-cheat-sheet