Ubuntu Linux distribution provides different ways to restart network or networking services from the command line or graphical user interface (GUI). In this tutorial, we will learn how to restart the network by checking the network status. You can use the following methods to restart the network in Ubuntu. These methods can be used for Ubuntu distribution versions like Ubuntu 16.04, Ubuntu 16.10, Ubuntu 17.04, Ubuntu 17.10, Ubuntu 18.04, Ubuntu 18.10, Ubuntu 19.04, Ubuntu 19.10, Ubuntu 20.04 for all flavors like Desktop, Workstation, Server, and IoT.
- Using the systemctl command line to
- Using the service script
- Using the Desktop GUI (GNOME, XFCE, KDE)
- Using the Network Configuration GUI
- Using Netplan Command
- Using nmcli
Restart Ubuntu Network Using systemctl Command Line Tool
systemctl command is a defacto command to manage services in Linux distributions and Ubuntu. We can use the systemctl command to restart the network by restart networking services. We will provide the sudo in order to provide root privileges to change network service status. First, we will check the network or network service status with the
systemctl status command. The network service name for the systemctl command is
NetworkManager.service .This method is the most reliable way to restart network.
$ systemctl status NetworkManager.service
We can see that the network service is currently running. We will restart the NetworkManager.service with the
systemctl restart command like below by providing the service name.
$ sudo systemctl restart NetworkManager.service
We can see the service status and in the line starting with
Active we can see the
13s ago which shows how long the network service is running in this case how much time ago the service is restarted.
If you get an error like Unrecognized Service error please check the service name which may be mistyped.
Restart Ubuntu Network Using service Command Line Tool
service command-line tool is used to manage Ubuntu services and created as an alternative to the systemctl command. We can use the service command in order to restart the network or network service. First we will check the network service status which is called as
$ service network-manager status
And then we will restart the network with the restart parameter like below.
$ service network-manager restart
Restart Ubuntu Network Using network-manager init.d or SystemV Command Line Tool
An alternative to the systemctl command to restart the network in Ubuntu is the
init.d system where the service management script is named
network-manager. The complete path is
/etc/init.d/network-manager we will also provide the
restart parameter. This script also requires root privileges. Now first we will check current status of the network service with the following command by using the
$ sudo /etc/init.d/network-manager status
We can see that the Network service running properly. We will restart the service with the
restart parameter like below.
$ sudo /etc/init.d/network-manager restart
If you are using an older Ubuntu version which is 14.04 or older you can use the following init.d command to restart network. But keep in mind that this will not work with later versions of Ubuntu because it is deprecated.
$ sudo /etc/init.d/networking restart
Restart Network Netplan For Ubuntu Bionic
For older Ubuntu versions like Ubuntu Bionic previously defined methods may not work properly. Ubuntu provides the netplan command which is used to manage network.
$ sudo netplan apply
Restart Network nmcli Command
nmcli is a command-line tool for controlling NetworkManager GUI. The nmcli can be used to restart the network from the command-line. First, we will turn off the networking and then turn on like below.
$ sudo nmcli networking off $ sudo nmcli networking on
Restart All Network Interface (Ethernet or Wireless)
Previously described methods will restart the network service and all related tools completely. Alternatively, we can restart a specific network interface which can be ethernet or wireless by using the ifdown and ifup commands. ifdown command will stop the interface and ifup command will start the interface where both of them require root privileges.
#Stop all network interfaces $ sudo ifdown -a #Start all network interfaces $ sudo ifup -a