---
name: "hostname"
section: "1"
platform: "openbsd"
package: "man"
version: "8.0-current-20261101"
release: "OpenBSD 8.0-current (2026-11-01)"
platforms: ["linux", "freebsd", "openbsd", "macos"]
url: "https://new.carta.tech/hostname"
---

# hostname(1)

set or print name of current host system

## NAME

**hostname** – set or print name of current host system

## SYNOPSIS

**hostname** \[**-s**\] \[*name-of-host*\]

## DESCRIPTION

The **hostname** utility is used to set or print the name of the current host. If no argument is given, the name of the current host is printed.

The host name can be set by the superuser either by specifying *name-of-host*, or by supplying a [myname(5)](/myname/5.md) file, which is used at system boot time by [rc(8)](/rc/8.md) to initialize the hostname.

The options are as follows:

- **-s**

  Trims off any domain information from the printed name.

## SEE ALSO

[domainname(1)](/domainname/1.md), [gethostname(3)](/gethostname/3.md), [myname(5)](/myname/5.md), [hostname(7)](/hostname/7.md), [rc(8)](/rc/8.md)

## HISTORY

The **hostname** utility appeared in 4.2BSD.
