Notifications
Clear all

How to Delete All Network Interfaces Permanently on Ubuntu


(@sravan)
Script Novice
Joined: 10 months ago
Posts: 39
Topic starter  

If you need to delete all network interfaces on your Ubuntu system permanently, whether for troubleshooting, reconfiguring your network setup, or starting fresh, this guide will walk you through the steps.

Important Note:

Deleting all network interfaces will disconnect your system from all networks, including the internet. Make sure you have a plan to restore or reconfigure your network settings afterward, especially if you're doing this on a remote server.

Steps to Delete All Network Interfaces Permanently:

  1. Back Up Your Network Configuration:

    Before making any changes, it's a good idea to back up your current network configuration. This way, you can restore it if needed.

    sudo cp /etc/netplan/*.yaml ~/network-backup/

    This command copies your Netplan configuration files (usually located in /etc/netplan/) to a backup directory in your home folder.

  2. Remove Netplan Configuration Files:

    Netplan is the default network configuration tool on Ubuntu. To delete all network interfaces, you need to remove the configuration files.

    sudo rm /etc/netplan/*.yaml

    This command will delete all YAML configuration files in the /etc/netplan/ directory, effectively removing all network interfaces configured by Netplan.

  3. Apply the Changes:

    After deleting the configuration files, apply the changes to remove the network interfaces.

    sudo netplan apply

    This command applies the new configuration (or in this case, the lack of it), which will disconnect your system from any networks.

  4. Disable and Remove Network Manager (Optional):

    If you’re using Network Manager, you may also want to disable and remove it. Be cautious with this step, as it will also remove any network configurations managed by Network Manager.

    sudo systemctl stop NetworkManager
    sudo systemctl disable NetworkManager
    sudo apt-get purge network-manager

    These commands stop and disable the Network Manager service and then remove it from your system.

  5. Reboot Your System:

    Finally, reboot your system to ensure all changes take effect.

    sudo reboot

Restoring Network Interfaces:

If you need to restore network functionality, you can either recreate the YAML configuration files in /etc/netplan/ or reinstall Network Manager using:

sudo apt-get install network-manager

You can then create new network configurations as needed.


   
Quote
Share: