LinuxCommandLibrary

avahi-set-host-name

Set the machine's Avahi host name

SYNOPSIS

avahi-set-host-name [options] HOSTNAME

PARAMETERS

-h, --help
    Print brief usage information and exit

-V, --version
    Print version string and exit

DESCRIPTION

The avahi-set-host-name command dynamically changes the host name that the Avahi daemon advertises over the local network using Multicast DNS (mDNS). Avahi is Linux's implementation of Apple's Zeroconf/Bonjour protocol, enabling automatic hostname resolution without a central DNS server.

This tool sends a D-Bus message to the running Avahi daemon to update the published host name. It does not alter the system's persistent host name (e.g., /etc/hostname or hostnamectl). This makes it ideal for temporary adjustments, testing, or environments where full system changes are restricted.

The new host name can be a simple label (e.g., 'mylaptop') or a pretty name with spaces (e.g., 'My Laptop'). Avahi appends the domain (usually '.local') automatically. The change takes effect immediately if the daemon is running and supports D-Bus publishing.

Requires root privileges or membership in the 'avahi' group. Useful in home networks, IoT setups, or printer sharing where devices need friendly, discoverable names.

CAVEATS

Requires Avahi daemon running with D-Bus support. Changes are lost on daemon restart or reboot. Host name must be valid mDNS label (RFC 6762); avoid dots except for domain. Run as root or avahi group member.

EXAMPLES

avahi-set-host-name mylaptop
Sets host name to 'mylaptop.local'.

avahi-set-host-name "John's Laptop"
Sets pretty host name with spaces.

VERIFICATION

Use avahi-browse -a or avahi-resolve-host-name mylaptop.local to confirm the change.

HISTORY

Introduced in Avahi 0.6 (2006) by Lennart Poettering as part of avahi-utils. Avahi project began in 2004 to provide mDNS/DNS-SD for Linux desktops.

SEE ALSO

Copied to clipboard