How to get fqdn in linux

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: To get the Fully Qualified Domain Name (FQDN) in Linux, you can use the `hostname -f` command. This command queries the system's network configuration to resolve its own hostname to its FQDN.

Key Facts

What is an FQDN?

A Fully Qualified Domain Name (FQDN), also known as an absolute domain name, is the complete domain name for a specific computer, or host, on the internet. It is a string of characters that unambiguously identifies the host's location in the hierarchical Domain Name System (DNS). An FQDN consists of a hostname and a domain name. For example, in `server1.example.com`, `server1` is the hostname, and `example.com` is the domain name.

Why is the FQDN Important?

The FQDN is crucial for network communication and identification. It ensures that each device on a network has a unique and resolvable address. This is vital for services like email, web hosting, and secure connections (SSL/TLS certificates), which rely on accurate domain name resolution to function correctly. Without a proper FQDN, a server might not be accessible by its intended name, leading to connectivity issues.

How to Get the FQDN in Linux

The primary command-line utility for retrieving the FQDN on most Linux distributions is hostname. Specifically, using the -f flag tells the command to resolve and display the FQDN.

Using the hostname -f Command

Open your terminal and type the following command:

hostname -f

This command will output the FQDN of your Linux system. For instance, if your system's FQDN is my-linux-box.localdomain, that's what will be displayed.

Understanding the Output

The output of hostname -f is the system's FQDN. If it returns just the hostname or an unexpected result, it often indicates a misconfiguration in the system's network settings.

Alternative Commands and Methods

While hostname -f is the standard, other commands and methods can provide similar information or help diagnose FQDN issues:

Troubleshooting FQDN Issues

If hostname -f is not returning the correct FQDN, the issue usually lies in the system's network configuration files. Here are the common places to check:

By understanding and correctly configuring these settings, you can ensure that your Linux system has a properly resolved FQDN, facilitating smooth network operations.

Sources

  1. Fully qualified domain name - WikipediaCC-BY-SA-4.0
  2. hostname(1) - Linux man pagesCC-BY-4.0
  3. How to Set Up and Use DNS with BIND on CentOS 7fair-use

Missing an answer?

Suggest a question and we'll generate an answer for it.