Home>Article>Operation and Maintenance> How to restart network service in ubuntu

How to restart network service in ubuntu

John Lennon
John Lennon Original
2020-06-12 15:44:41 37668browse

How to restart network service in ubuntu

The method for restarting the network service in Ubuntu is:

Are you using an Ubuntu-based system and then find that you cannot connect to the network? You will be surprised how many problems can be solved simply by restarting the service.

In this article, I will introduce several methods to restart the network in Ubuntu or other Linux distributions. You can choose the corresponding method according to your own needs. These methods are basically divided into two categories:

Restart the network through the command line

If you are using the Ubuntu server version, then you are already using the command line terminal. If you are using the desktop version, you can open the command line terminal through the shortcut Ctrl Alt T Ubuntu keyboard shortcut .

In Ubuntu, there are multiple commands to restart the network. Some or most of these commands are also suitable for restarting the network in Debian or other Linux distributions.

1. Network manager service

This is the easiest way to restart the network through the command line. It is equivalent to restarting the network through the graphical interface (restarting the Network-Manager service).

sudo service network-manager restart

At this time, the network icon will disappear for a while and then reappear.

2. The systemd

service command is just an encapsulation of this method (it is also an encapsulation of the init.d series scripts and Upstart related commands). The systemctl command has far more functions than the service command. Usually I prefer to use this command.

sudo systemctl restart NetworkManager.service

At this time, the network icon will disappear for a while. If you want to know about other options of systemctl, you can refer to the man help documentation.

3. nmcli

This is another tool that can manage the network on Linux. This is a powerful and practical tool. Many system administrators like to use this tool because it is very easy to use.

This method has two steps: turn off the network, and then turn on the network.

sudo nmcli networking off

This will turn off the network and the network icon will disappear. Next, turn on the network:

sudo nmcli networking on

You can learn more about the usage of nmcli through the man help document.

4. ifup & ifdown

These two commands directly operate the network port and switch whether the network port can send and receive packets. This is one of the most important network commands in Linux that you should know.

Use ifdown to close all network ports, and then use ifup to re-enable the network ports.

The generally recommended approach is to use these two commands together.

sudo ifdown -a && sudo ifup -a

Note: This method will not make the network icon disappear from the system tray. In addition, various network connections will also be disconnected.

Supplementary tools: nmtui

This is another method commonly used by system administrators. It is a text menu tool for managing networks in a command line terminal.

nmtui

Open the following menu:

How to restart network service in ubuntu

Note: In nmtui, you can select options through the up and down arrow keys.

Select "Activate a connection":

How to restart network service in ubuntu

Press the Enter key to open the "connections" menu

How to restart network service in ubuntu

Next, select the network preceded by an asterisk (*). In this case, it's the MGEO72.

How to restart network service in ubuntu

Press the Enter key. This will "deactivate" your Internet connection.

How to restart network service in ubuntu

Select the network you want to connect to:

How to restart network service in ubuntu

Press the Enter key. This reactivates the selected network connection.

How to restart network service in ubuntu

Press the Tab key twice and select "Back":

How to restart network service in ubuntu

Press the Enter key to return Main menu of nmtui.

How to restart network service in ubuntu

Select “Quit”:

1How to restart network service in ubuntu

Exit this interface and return to the command line terminal.

That’s it, you have successfully restarted the network.

Recommended tutorial: "linux tutorial"

The above is the detailed content of How to restart network service in ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn