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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. dm-tool: command not found
  2. A File Is Claimed to Be Disappearing – How to monitor a file for deletion in Linux
  3. CentOS / RHEL : How to block incoming and outgoing ports using iptables
  4. How to add Swap Space on Linux Servers (CentOS/RHEL) On the Fly
  5. Understanding Linux SCSI Reservation
  6. How to install virtual machines optimized and configured for the Red Hat Virtualization environment
  7. pvscan Command Examples in Linux
  8. How to load SELinux Module For Oracleasm
  9. a2disconf: command not found
  10. lshal Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright