33

I'm using Ubuntu 18.04.1 LTS. I want to disable network manager on an Ubuntu machine, because (1) I don't need it, (2) I prefer having hardcoded configuration, and (3) network manager regularly causes issues by changing the DHCP configuration.

I tried to follow the official documentation:

Stop network manager

sudo systemctl stop NetworkManager.service

Disable network manager (permanently) to avoid it restarting after a reboot

sudo systemctl disable NetworkManager.service

Despite this, the network manager is back again every time I reboot the machine.

How can I make it go away?

Arseni Mourzenko
  • 4,582
  • 5
  • 20
  • 34
  • 2
    Is there a reason you cannot simply uninstall NM? – user535733 Nov 10 '18 at 11:40
  • What do you want to use instead of NetworkManager - netplan as in server? – N0rbert Nov 10 '18 at 11:48
  • @user535733: I didn't know network manager can be uninstalled. I'll check this one. – Arseni Mourzenko Nov 10 '18 at 11:49
  • 3
    @N0rbert: just hardcoded configuration in /etc/network/interfaces and in /etc/resolv.conf. Don't know if there is an official name for that. – Arseni Mourzenko Nov 10 '18 at 11:50
  • @ArseniMourzenko What is your desktop environment? If it is GNOME, then purging network-manager will remove gnome-control-center, which is essential part of GNOME. – N0rbert Nov 10 '18 at 11:59
  • I can't link questions on here I believe this is (indirectly?) related to my question https://askubuntu.com/questions/938062/prevent-network-manager-controlling-rndis-interfaces the common theme being "how can I prevent network manager taking over things that I don't want it to" – Rodney Nov 10 '18 at 22:54
  • @N0rbert: Try apt-holepunch (https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=625801;filename=apt-holepunch;msg=29) by me from debian bug #625801 (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=625801). – Joshua Nov 11 '18 at 02:55
  • Find Lennart Poettering and chop off his fingers in case he ever tries to write any more software. Systemd: a disaster (but you can sort of understand where that comes from). Pulseaudio, eugh, open a web browser it changes your system audio limits, close it it changes it again open mplayer it changes it again. Then there's network manager, what does network manager actually offer apart from a confusing extra layer of garbage that sits on top of ifconfig? – Owl Aug 08 '20 at 18:08

2 Answers2

36

The method depends on desktop environment:

  • For Ubuntu MATE 18.04 LTS and 20.04 LTS purging network-manager package is safe. You can simply run:

    sudo apt-get purge network-manager
    
  • For Ubuntu 18.04 LTS and 20.04 LTS with GNOME desktop purging network-manager package will also purge ubuntu-desktop and gnome-control-center (essential part of GNOME desktop). So it is not an option.

    Here you should disable NetworkManager service (as you have already done):

    sudo systemctl stop NetworkManager.service
    sudo systemctl disable NetworkManager.service
    

    and three more services:

    sudo systemctl stop NetworkManager-wait-online.service
    sudo systemctl disable NetworkManager-wait-online.service
    

    sudo systemctl stop NetworkManager-dispatcher.service sudo systemctl disable NetworkManager-dispatcher.service

    sudo systemctl stop network-manager.service sudo systemctl disable network-manager.service

    and then reboot.


Notes:

  1. You can read more about network configuration with /etc/network/interfaces from Ubuntu 16.04 LTS Server Guide.
  2. Modern Ubuntu 18.04 LTS server uses netplan, you can read about it in the Ubuntu 18.04 LTS Server Guide.
N0rbert
  • 99,918
  • 1
    I always purge NetworkManager as one of my first post-install steps -- since at least 14. Perhaps this issue with the removal of the desktop was a bug? – Stephen Boston Sep 12 '19 at 01:35
  • 1
    Not a bug, but dependency issue. – N0rbert Sep 12 '19 at 10:10
  • Has it been resolved? Or is there a difference between our repositories? I have not had the experience you report with purging NM. I have found that some applications assume NM to be installed and active but none of them have been unique or essential. – Stephen Boston Sep 12 '19 at 10:45
  • For me the issue persists. Tested on minimal 18.04 LTS VM with sudo apt-get install ubuntu-desktop^ followed by sudo apt-get purge network-manager. – N0rbert Sep 13 '19 at 18:17
  • How very strange! I had a 19.10 VM that I hadn't played with yet so NM was still installed. I purged it, ran update and upgrade, and the desktop runs perfectly. I saw the upgrade think about upgrading NM but after reboot it is still not installed. – Stephen Boston Sep 13 '19 at 20:47
  • Thanks N0rbert! I was recently having issues with my server where every so many days it would just go offline to the internet but work locally just fine. I would restart the networking service and everything seemed OK. This actually saved me because I am running ifupdown instead of NetworkManager and they conflict apparently with each other, so this solved my headaches! Thanks again! – Terrance Mar 14 '22 at 01:48
  • 1
    FWIW, I think the difference the commenters face is due to different dependency settings. If you have "recommends" set to be installed then "*-desktop" will be "required" preventing removal of it's downstream dependencies. – pbhj Jan 31 '23 at 10:37
9

Try the mask command:

sudo systemctl stop NetworkManager.service
sudo systemctl mask NetworkManager.service

mask NAME...

Mask one or more units, as specified on the command line. This will link these unit files to /dev/null, making it impossible to start them.
This is a stronger version of disable, since it prohibits all kinds of activation of the unit, including enablement and manual activation. Use this option with care. This honors the --runtime option to only mask temporarily until the next reboot of the system.
The --now option may be used to ensure that the units are also stopped. This command expects valid unit names only, it does not accept unit file paths.

abu_bua
  • 10,783