Questo contenuto non è disponibile nella lingua selezionata.

6.3. Configuring Host Names Using hostnamectl


The hostnamectl tool is provided for administering the three separate classes of host names in use on a given system.

6.3.1. View All the Host Names

To view all the current host names, enter the following command:
~]$ hostnamectl status
Copy to Clipboard Toggle word wrap
The status option is implied by default if no option is given.

6.3.2. Set All the Host Names

To set all the host names on a system, enter the following command as root:
~]# hostnamectl set-hostname namehostnamectl set-hostname name
Copy to Clipboard Toggle word wrap
This will alter the pretty, static, and transient host names alike. The static and transient host names will be simplified forms of the pretty host name. Spaces will be replaced with - and special characters will be removed.

6.3.3. Set a Particular Host Name

To set a particular host name, enter the following command as root with the relevant option:
~]# hostnamectl set-hostname name [option...]hostnamectl set-hostname name [option...]hostnamectl set-hostname name [option...]hostnamectl set-hostname name [option...]hostnamectl set-hostname name [option...]
Copy to Clipboard Toggle word wrap
Where option is one or more of: --pretty, --static, and --transient.
If the --static or --transient options are used together with the --pretty option, the static and transient host names will be simplified forms of the pretty host name. Spaces will be replaced with - and special characters will be removed. If the --pretty option is not given, no simplification takes place.
When setting a pretty host name, remember to use the appropriate quotation marks if the host name contains spaces or a single quotation mark. For example:
~]# hostnamectl set-hostname "Stephen's notebook" --pretty
Copy to Clipboard Toggle word wrap

6.3.4. Clear a Particular Host Name

To clear a particular host name and allow it to revert to the default, enter the following command as root with the relevant option:
~]# hostnamectl set-hostname "" [option...]hostnamectl set-hostname "" [option...]hostnamectl set-hostname "" [option...]hostnamectl set-hostname "" [option...]hostnamectl set-hostname "" [option...]
Copy to Clipboard Toggle word wrap
Where "" is a quoted empty string and where option is one or more of: --pretty, --static, and --transient.

6.3.5. Changing Host Names Remotely

To execute a hostnamectl command on a remote system, use the -H, --host option as follows:
~]# hostnamectl set-hostname -H [username]@hostnamehostnamectl set-hostname -H [username]@hostnamehostnamectl set-hostname -H [username]@hostnamehostnamectl set-hostname -H [username]@hostnamehostnamectl set-hostname -H [username]@hostnamehostnamectl set-hostname -H [username]@hostname
Copy to Clipboard Toggle word wrap
Where hostname is the remote host you want to configure. The username is optional. The hostnamectl tool will use SSH to connect to the remote system.
Torna in cima
Red Hat logoGithubredditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi. Esplora i nostri ultimi aggiornamenti.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita il Blog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

Theme

© 2025 Red Hat