hostname(1)

hostname1

Set or print the name of current host system

Usage

hostname [-f] [{-s | -d}] [name-of-host]

Overview

The hostname utility prints the name of the current host. The super-user can set the hostname by supplying an argument; this is usually done in the initialization script /etc/rc.d/hostname, normally run at boot time. This script uses the hostname variable in /etc/rc.conf.

Options:

-f

Include domain information in the printed name. This is the default behavior.

-s

Trim off any domain information from the printed name.

-d

Only print domain information.

Examples

Set the host name of the machine and check the result:

$ hostname beastie.localdomain.org
$ hostname
beastie.localdomain.org

Do not show domain information:

$ hostname -s
beastie

Show only domain information:

$ hostname -d
localdomain.org

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 50 times.

  1. 2.0.5
  2. 2.1.5–2.1.7.1
  3. 2.2.2
  4. 2.2.5–2.2.6
  5. 2.2.7–2.2.8
  6. 2.2.9
  7. 3.0–3.2
  8. 3.3–3.4
  9. 3.5–3.5.1
  10. 4.0–4.2
  11. 4.3
  12. 4.4–4.5
  13. 4.6–4.11
  14. 5.0–5.2.1
  15. 5.3–5.4
  16. 5.5
  17. 6.0–6.2
  18. 6.3
  19. 6.4
  20. 7.0
  21. 7.1
  22. 7.2
  23. 7.3
  24. 7.4
  25. 8.0
  26. 8.1
  27. 8.2
  28. 8.3
  29. 8.4
  30. 9.0
  31. 9.1
  32. 9.2
  33. 9.3
  34. 10.0
  35. 10.1
  36. 10.2
  37. 10.3
  38. 10.4
  39. 11.0
  40. 11.1
  41. 11.2
  42. 11.3
  43. 11.4
  44. 12.0
  45. 12.1
  46. 12.2
  47. 12.3
  48. 12.4
  49. 13.0–13.2
  50. 13.3–14.5
  51. 15.0–16.0

-d since FreeBSD 11.1-RELEASE; -f since FreeBSD 6.3-RELEASE.

History

The hostname command appeared in 4.2BSD.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.