# Fichier: /etc/hostname

**URL:** <https://forumsdulibre.quebec/t/fichier-etc-hostname/1749>\
**Category:** Savoir libre\
**Tags:** programmation\
**Created:** [Août 8, 2023, 6:00 UTC](https://forumsdulibre.quebec/t/fichier-etc-hostname/1749 "2023-08-08T18:00:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michel-Andre](https://forumsdulibre.quebec/user_avatar/forumsdulibre.quebec/michel-andre/32/334_2.png) [@Michel-Andre](https://forumsdulibre.quebec/u/Michel-Andre)\
**Post date:** [Août 8, 2023, 6:00 UTC](https://forumsdulibre.quebec/t/fichier-etc-hostname/1749/1 "2023-08-08T18:00:48Z")

</div>

Salut à tous,

Que devrait contenir le fichier `/etc/hostname`: le nom du serveur seulement c’est-à-dire l’alias du FQDN contenu dans /etc/hosts

Selon la page man de Debian-12 pour `hostname`:

> **/etc/hostname** Historically this file was supposed to only contain the hostname **and not the full canonical FQDN**. Nowadays most software is able to cope with a full FQDN here. This file is read at boot time by the system initialization scripts to set the hostname.
> 
> **/etc/hosts** Usually, this is where one sets the domain name by aliasing the host name to the FQDN

> The FQDN (Fully Qualified Domain Name) of the system is the name that the resolver(3) returns for the host name, such as, _ursula . example . com_. It is usually the hostname followed by _**the DNS domain name (the part after the first dot**_). You can check the FQDN using **hostname --fqdn** or the domain name using **dnsdomainname**.
> 
> You cannot change the FQDN with **hostname** or **dnsdomainname**.
> 
> The recommended method of setting the FQDN is to _ **make the hostname be an alias for the fully qualified name using** _ _/etc/hosts_, DNS, or NIS. For example, if the hostname was «&nbsp;ursula&nbsp;», one might have a line in _/etc/hosts_ which reads
> 
> 127.0.1.1 [ursula.example.com](http://ursula.example.com) ursula

**/etc/host**

```auto
127.0.1.1 ursula.example.com ursula
# Ici l'alias du FQDN `ursula.example.com` est `ursula`.

```

**/etc/hostname**  
`ursula`

Michel-André

---

<div class="post-metadata">

**Author:** ![renaudb](https://forumsdulibre.quebec/letter_avatar_proxy/v4/letter/r/e480ec/32.png) [@renaudb](https://forumsdulibre.quebec/u/renaudb)\
**Post date:** [Août 13, 2023, 2:06 UTC](https://forumsdulibre.quebec/t/fichier-etc-hostname/1749/2 "2023-08-13T14:06:14Z")

</div>

Je ne sais pas c’est quoi ton contexte, mon typiquement le contenu de `/etc/hostname`, c’est le nom de ta «&nbsp;machine&nbsp;» tel qu’il apparaîtra aux autres ordinateurs sur un réseau local, et dans ton «&nbsp;invite de commande&nbsp;» (prompt) dans un terminal… Bref, ça en prend un, mais c’est juste un nom identificateur, ça aura probablement très peu d’impact sur tes activités, à moins que tu es des besoins très spécifiques de réseautage, et même encore… Donc, n’importe quel mot qui réfère à ton ordinateur, ou n’importe quoi…: «&nbsp;portable-michel&nbsp;», «&nbsp;laptop&nbsp;», «&nbsp;alpha&nbsp;», «&nbsp;petit-cheval&nbsp;»…! Pas d’espace, pas de caractères spéciaux, un seul mot (incluant les tirets et les \_ au besoin).

Sur Debian, tu peux paramétrer le hostname avec la commande: `hostnamectl set-hostname <le_nom_de_ta_machine>`. Ça écrit simplement le nom d’hôte dans le fichier `/etc/hostname`.

---

<div class="post-metadata">

**Author:** ![Michel-Andre](https://forumsdulibre.quebec/user_avatar/forumsdulibre.quebec/michel-andre/32/334_2.png) [@Michel-Andre](https://forumsdulibre.quebec/u/Michel-Andre)\
**Post date:** [Août 13, 2023, 2:22 UTC](https://forumsdulibre.quebec/t/fichier-etc-hostname/1749/3 "2023-08-13T14:22:39Z")

</div>

Salut @renaudb

Je suis complètement d’accord.

Pour le contexte, voir: [What is the hostname format? - Support - NethServer Community](https://community.nethserver.org/t/what-is-the-hostname-format/22018).

Michel-André
