Welcome, Guest

Author Topic: systemctl/ hostnamectl/ timedatectl and dbus  (Read 3139 times)

thom_nic

  • Newbie
  • *
  • Posts: 28
  • Karma: +1/-0
systemctl/ hostnamectl/ timedatectl and dbus
« on: January 06, 2017, 04:30:08 PM »
I'm using release 5 of the official Debian image and it seems the dbus session bus is not running (or maybe dbus is not installed at all? `ps ax|grep dbus` shows nothing...)

Code: [Select]
root@AM335x:~# systemctl --user
Failed to get D-Bus connection: Connection refused

root@AM335x:~# hostnamectl
Failed to create bus connection: No such file or directory

root@AM335x:~# timedatectl
Failed to create bus connection: No such file or directory

The application I'll be building wants to do things like configure network settings, hostname, etc.  Using systemd utilities (and dbus more generally) to accomplish this seemed like it might be a better way to go vs e.g. writing directly to files in /etc/.  Thanks in advance!


thom_nic

  • Newbie
  • *
  • Posts: 28
  • Karma: +1/-0
Re: systemctl/ hostnamectl/ timedatectl and dbus
« Reply #1 on: November 02, 2017, 07:45:38 PM »
To answer my own old question...

systemctl works fine without dbus only when run as root (which you pretty much always need to run as root anyway)

instead of hostnamectl I do the "classic": write to /etc/hostname then sudo hostname -f /etc/hostname

instead of timedatectl I use the "classic" form:

ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime to set timezone

write to `/etc/systemd/timesyncd.conf` and `sudo systemctl reload systemd-timesyncd`