How do I disable network manager permanently?

Solution 1:

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.

Solution 2:

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.