hostnamectl command is failing with an error "Could not set property: Access denied"

Solution Verified - Updated -

Issue

  • hostnamectl command is failing with the following error.
[root@localhost]# hostnamectl set-hostname test-vm
Could not set property: Access denied

or

[root@localhost]# hostnamectl set-hostname test-vm
Could not set static hostname: Not allowed to update /etc/hostname.
  • In /var/log/message the following error messages are found.
Dec 28 04:07:11 localhost systemd-hostnamed: Failed to write static host name: Permission denied
Dec 28 04:07:11 localhost systemd-hostnamed: Failed to write static host name: Permission denied

Environment

  • Red Hat Enterprise Linux (RHEL) 7
  • Red Hat Enterprise Linux (RHEL) 8
  • Red Hat Enterprise Linux (RHEL) 9
  • Red Hat Enterprise Linux (RHEL) 10
  • Hostnamectl

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content