14

I add some a line dns-nameservers 8.8.8.8 in my /etc/network/interfaces. I want to reload this config without reboot.

However, when I tried: sudo service networking restart
I got a Unit networking.service not found error

sudo /etc/init.d/networking restart
I got /etc/init.d/networking: command not found

How can I fix this? I use Ubuntu Server 18.04.2 LTS

2 Answers 2

18

Things have changed over time. Dependent on your installation, you want to check the service names with

systemctl list-unit-files | grep -i network

And, most likely in your case, it's

systemctl restart NetworkManager
7
  • Unit NetworkManager.service not found on Ubuntu 18.04 server.
    – Kaz
    Dec 24, 2020 at 23:17
  • @Kaz What's your output of systemctl list-unit-files | grep -i network? Dec 26, 2020 at 18:59
  • Like this: pastebin.com/raw/1pmmHw9G
    – Kaz
    Dec 26, 2020 at 19:20
  • 3
    @Kaz Yeah, thanks. Then your networking is managed without NetworkManager and solely by systemd-networkd. In your case it's systemctl restart systemd-networkd then. Dec 27, 2020 at 17:19
  • 2
    An Ubuntu update on 20.10 changed it for me today apparently from network-manager to NetworkManager Feb 11, 2021 at 9:42
0

Since version 15.04, Ubuntu comes with systemd as default instead of initd. systemd-networkd exactly

Use systemctl restart networking

1
  • 3
    Results in Unit networking.service not found on Ubuntu 18.04 server.
    – Kaz
    Dec 24, 2020 at 23:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.