Files
bash.softwareshinobi.com/docs/Linux-Commands/System/065-the-hostnamectl-command.md
Software Shinobi 2b2c77b808
All checks were successful
learn org at code.softwareshinobi.com/bash.softwareshinobi.com/pipeline/head This commit looks good
automated terminal push
2025-06-04 20:16:44 -04:00

1.0 KiB
Executable File

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