Skip to content

hostnamectl command

Show or change the host name and system details.

On this page

Syntax

hostnamectl [command]

Provided by the systemd package. Run man hostnamectl for the full manual.

Common options

OptionWhat it does
statusHost name, OS, kernel, hardware
set-hostname NAMEChange the host name
--static / --prettyWhich name to show or set

Examples

  1. Show host and OS details

    hostnamectl
  2. Change the host name

    sudo hostnamectl set-hostname web01
  3. Print just the host name

    hostname
  4. Print the IP addresses

    hostname -I

Tips

  • Also update the name in /etc/hosts after a change.

hostnamectl guides

← All Linux commands · Suggest a fix

Back to top