Forrest logo
tool overview
On this page you find all important commands for the CLI tool hostnamectl. If the command you are looking for is missing please ask our AI.

hostnamectl

Hostnamectl is a command-line tool that allows users to view and modify the hostname and related system information in a Linux system. It is available in systemd-based distributions such as Ubuntu, CentOS, and Fedora.

Using hostnamectl without any options displays the current system hostname, operating system, kernel version, architecture, and other relevant information.

The set-hostname option can be used to change the system hostname. This requires superuser privileges, so users need to execute the command with sudo or as root.

Hostnamectl also provides the capability to set a static hostname, which persists across reboots, or a transient hostname, which only lasts until the next reboot.

Additionally, hostnamectl enables users to set a pretty or iconic hostname, which is a user-friendly version of the actual hostname.

The tool also supports setting the chassis type, which provides information about the hardware platform, such as virtual, laptop, desktop, server, etc.

Hostnamectl allows users to print a list of available locales and set the system's default locale.

Furthermore, hostnamectl supports setting the time zone of the system, providing a convenient way to configure the correct local time.

Users can check the status of the hostname and related system information by executing the status option of the hostnamectl command.

Overall, hostnamectl simplifies the process of managing hostname and system information, making it easier for users to configure and monitor their Linux systems.

List of commands for hostnamectl:

  • hostnamectl:tldr:01d03 hostnamectl: Reset hostname to its default value.
    $ sudo hostnamectl set-hostname --pretty ""
    try on your machine
    explain this command
  • hostnamectl:tldr:d05c4 hostnamectl: Get the hostname of the computer.
    $ hostnamectl
    try on your machine
    explain this command
  • hostnamectl:tldr:e1bae hostnamectl: Set the hostname of the computer.
    $ sudo hostnamectl set-hostname "${hostname}"
    try on your machine
    explain this command
  • hostnamectl:tldr:e755d hostnamectl: Set a pretty hostname for the computer.
    $ sudo hostnamectl set-hostname --static "${hostname-example-com}" && sudo hostnamectl set-hostname --pretty "${hostname}"
    try on your machine
    explain this command
tool overview