May 28, 2024 2 min read

FQDNs

FQDNs
Photo by NASA / Unsplash

A fully qualified domain name (FQDN) is a complete name given to a host that resides within a domain. The domain could be generated by Active Directory/FreeIPA or part of a web server hierarchy. Regardless of the operating system, the naming convention is the same:
hostname + domain name = FQDN

For example: the hostname: workstation1 plus the domain name: example.local would become:

workstation1.example.local

Note: These are also known simply as "DNS names".

Check out the video below (and mini-lab) to learn how to work with hostnames in Linux.

VIDEO

📽️
Check out the Linux Networking - Basics & Beyond video course: available on O'Reilly and InformIT. (For InformIT, use the code PROWSE70 at checkout to receive a 70% discount.)

Lab 24 ⚙️ Configuring a Hostname in the Terminal

We've done plenty up to this point with IP addresses. But most systems (and people) communicate by name. So a technician needs to know how to modify hostnames and configure DNS. Remember that the Domain Name System (DNS) is in charge of resolving domain names (and host names) to their respective IP addresses - and vice-versa.

Working with hostnamectl

  • View system information with the hostnamectl command

    Type hostnamectl to see the hostname and other information about the system. Example:

    root@deb52:~# hostnamectl
      Static hostname: deb52
            Icon name: computer-vm
              Chassis: vm
             Location: workplace2
           Machine ID: 42f779dc9123405c90f8fa73b6c83f7c
              Boot ID: 35b9c976794a4bb38ba7a4e81511152a
       Virtualization: kvm
     Operating System: Debian GNU/Linux 10 (buster)
               Kernel: Linux 4.19.0-16-amd64
         Architecture: x86-64
    

    Here we see the name of the computer is deb52. We get a whole lot of other information as well, including the operating system type and version, the version of the Linux kernel, and the architecture of the computer.

  • Use the hostnamectl command to change the hostname.

    • First, change the name by typing hostnamectl set-hostname newname
    • View the new name by entering hostnamectl
    • Close the terminal and open a new one to see the new name in the prompt.
    • Change the name back to the original.
    • Close the terminal and open a new one again.
    • Verify the name is back to the original. (You can also use the older hostname command to see the hostname only.)

    Example: (the four dashes represents closing the terminal and reopening it)

    root@deb52:~# hostnamectl set-hostname newname
    root@deb52:~# hostnamectl
       Static hostname: newname
             Icon name: computer-vm
               Chassis: vm
              Location: workplace2
            Machine ID: 42f779dc9123405c90f8fa73b6c83f7c
               Boot ID: 35b9c976794a4bb38ba7a4e81511152a
        Virtualization: kvm
      Operating System: Debian GNU/Linux 10 (buster)
                Kernel: Linux 4.19.0-16-amd64
          Architecture: x86-64
    ----
    root@newname:~# hostnamectl set-hostname deb52
    ----
    root@deb52:~# hostname
    deb52
    

    Note: A fun program that shows similar information to hostnamectl is called neofetch. Install it by name with your distro's installer - for example apt install neofetch. Then run the program by simply typing neofetch.

👍 Excellent work!


📚 Further Study

Be sure to check the help file and manual page for hostnamectl

  • hostnamectl -h
  • man hostnamectl

Linux Networking - Basics & Beyond available now on O'Reilly and InformIT. (For InformIT, use the code PROWSE70 at checkout to receive a 70% discount.)
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Prowse Tech.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.