Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

title_fqdn switch does nothing #2094

Open
tidux opened this issue Apr 9, 2022 · 1 comment · May be fixed by #2095
Open

title_fqdn switch does nothing #2094

tidux opened this issue Apr 9, 2022 · 1 comment · May be fixed by #2095

Comments

@tidux
Copy link

tidux commented Apr 9, 2022

hostname and hostname -f return the same value on most modern GNU/Linux systems with an actual FQDN applied. Here's an example without redacting anything but my PS1.

$ hostname > /tmp/hostname
$ hostname -f > /tmp/full-hostname
$ diff /tmp/hostname /tmp/full-hostname 
$ 

As you can see, the outputs of the two commands are identical and non-empty. The environment variable $HOSTNAME also evaluates to the same string.

$ hostname > /tmp/hostname
$ echo $HOSTNAME > /tmp/env-hostname
$ diff /tmp/hostname /tmp/env-hostname
$

A better way to get the short hostname and ensure no domain information leaks is to do the following:

hostname=$(hostname | cut -d. -f1)

That guarantees that no domain information leaks by trimming all but the leftmost element in a hostname.

@tidux tidux linked a pull request Apr 9, 2022 that will close this issue
@zeus86
Copy link

zeus86 commented May 30, 2023

why not utilizing hostname -s, which is exactly made for this (and indeed on arch returns the shortname, even if hostname without parameters returns the fqdn-hostname).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants