Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 1.04 KB

065-the-hostnamectl-command.md

File metadata and controls

44 lines (31 loc) · 1.04 KB

The hostnamectl command

The hostnamectl command provides a proper API used to control Linux system hostname and change its related settings. The command also helps to change the hostname without actually locating and editing the /etc/hostname file on a given system.

Syntax

$ hostnamectl [OPTIONS...] COMMAND ...

where COMMAND can be any of the following

status: Used to check the current hostname settings

set-hostname NAME: Used to set system hostname

set-icon-name NAME: Used to set icon name for host

Example

  1. Basic usage to view the current hostnames
$ hostnamectl 

or

$ hostnamectl status
  1. To change the static host name to myhostname. It may or may not require root access
$ hostnamectl set-hostname myhostname --static
  1. To set or change a transient hostname
$ hostnamectl set-hostname myotherhostname --transient
  1. To set the pretty hostname. The name that is to be set needs to be in the double quote(” “).
$ hostname set-hostname "prettyname" --pretty