Ubuntu

How to Use nmcli in Ubuntu

Network manager manages all the network settings of the computer. With which network a machine should be connected, which type of traffic should be allowed and how to save data from the online servers are all managed by the network manager. Network managers have different tools, for example we have nm-connection-editor, nmcli, nm Gnome etc. All the tools or utilities have their own specific functions like nm-connection-editor is used to manage the wired connections of the machine, by Gnome settings we can manage all the network settings easily, by nmcli we can do the setting by the command line mode.

This write-up will demonstrate the installation of the network manager then in detail we will discuss the nmcli command for what purpose and how it can be used.

What is the installation procedure of Network Manager

Though the nmcli is installed by default in Ubuntu but in case if it is not installed we will install the network manager package. For the installation of the network manager we will first update our Ubuntu repository by opening the terminal and entering the following command for updating:

$ sudo apt update

Now we will install the network manager by using the following command.

$ sudo apt install network-manager

As it can be seen that the network manager is already installed. To start the network manager use:

$ sudo systemctl start network-manager

To confirm the above step we will check out the status of the network manager by using systemctl command as:

$ sudo systemctl status network-manager

What is nmcli

Sometimes we are managing the network setting by using the GUI (graphical user interface) but suddenly because of some issues the GUI crashes so we think about the other options to accomplish our results. An alternative to the GUI we have is command line methods. For the command line method we have the “nmcli” through which we can configure the network settings. There are different features which we can do by using this command. We will discuss them briefly.

nmcli command for General functions : Command nmcli can be used for the general functions like to check the status of wired connections for this purpose we used command as:

$ nmcli general status

We can also check the hostname by using this command:

$ nmcli general hostname

We can also check the permissions which are granted by the network manager as

$ nmcli general permissions

Nmcli command for the radio transmission control : We can check the status of the wifi whether it is on or off by the following command:

$ nmcli radio wifi

Nmcli command for monitoring : We can monitor the changes in different aspects like in connectivity state, devices using the nmcli command as:

$ nmcli monitor

If there some modifications made in the backend of network settings it will display them.

nmcli command for network management : We can manage the network setting using the nmcli command. In Ubuntu the configurations with the wireless devices are considered as connections.

We can display all the connections as:

$ nmcli connection show

We can also check the status of device by using the nmcli command:

$ sudo nmcli dev status

For more functions of nmcli command we can type man nmcli and the brief list will be available on Ubuntu:

Conclusion

The nmcli is the tool of the network manager mostly it is present in Ubuntu but in rare cases if it is not present then no need to panic we can still have it by installing the network manager package. In this write-up, we discussed the nmcli command and its functions briefly. Using the nmcli command we can check out the statuses of the wireless connections. We can also take a look at all the commands of nmcli by opening its manual through the “man” command. I Expect this writeup will make you understand the use of nmcli command.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.