I know that the first one is said to be canonical, but I don't fully understand the practical implications. This question was triggered by the man page for hostname -f, specifically when it says:
Technically: The FQDN is the name gethostbyname(2)
returns for the host name returned by gethostname(2).
The DNS domain name is the part after the first dot.
Let's assume that the computer hostname is foo.
With the following configuration:
127.0.0.1 localhost
127.0.1.1 foo.example.com foo
The command hostname -f returns foo.example.com.
While, with the following configuration:
127.0.0.1 localhost
127.0.1.1 foo foo.example.com
The command hostname -f returns foo.
Specifically, is the first hostname what man calls 'the official name of the host' when talking about hostent.h_name?
Note: I'm on Debian but hopefully these concepts are of general *nix interest.
Link: A possibly related question.
Link: This question suggests that the second style is wrong, nevertheless I've seen it applied several times around the web.