• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

hostnamectl: command not found

by admin

In most cases, systemctl is used to control services, but there are some additional systemd commands that you can use. For example, hostnamectl enables you to view the system’s network hostname and other information about the system’s hardware and the Linux kernel it is running. You can also use this command to change the system’s hostname.

Syntax

The syntax of the hostnamectl command is:

# hostnamectl [options] [subcommand] [arguments]

For example, to set the hostname to server01:

# hostnamectl set-hostname server01

If you encounter the below error while executing any hostnamectl command:

hostnamectl: command not found

you may try installing the systemd package as per your choice of distribution.

Distribution Command
Debian apt-get install systemd
Ubuntu apt-get install systemd
Arch Linux pacman -S systemd
Kali Linux apt-get install systemd
CentOS yum install systemd
Fedora dnf install systemd
Raspbian apt-get install systemd

hostnamectl Command Examples

1. Get the hostname of the computer:

# hostnamectl

2. Set the hostname of the computer:

# hostnamectl set-hostname "hostname"

3. Set a pretty hostname for the computer:

# hostnamectl set-hostname --static "hostname.example.com" && sudo hostnamectl set-hostname --pretty "hostname"

4. Reset hostname to its default value:

# hostnamectl set-hostname --pretty ""

Filed Under: Linux

Some more articles you might also be interested in …

  1. playerctl Command Examples in Linux
  2. checkupdates : Command Examples in Linux
  3. dpkg Command Examples in Linux
  4. gist: Upload code to https://gist.github.com
  5. pacman –database Command Examples in Arch Linux
  6. All Linux Compress/Decompress Commands
  7. pihole Command Examples in Linux
  8. “git fetch” Command Examples
  9. How to enable/disable wayland on Ubuntu 22.04
  10. s2i: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright