Ubuntu: How to connect to Wi-Fi via the command line (terminal)

Sometimes Ubuntu Network Manager can be really dodgy and you might be unable to connect to any Wi-Fi Hotspot via the GUI (Graphical user interface). The Network-Manager may fail to start and even when manually restarting the service via the terminal you might still face issues to connect to any Wi-Fi Hotspot, even to an already known and saved home network.

It’s really handy that the Network-manager has command-line tool for controlling the Network Manager. It’s called “nmcli

nmcli gives you the opportunity to connect/disconnect and also do some other things with the Network-Manager like turning your PC into a Wi-Fi Hotspot itself. Here are the basics commands you need in order to connect to any available network.

If you want to check all of your already saved connections run the following command:

In order to see the available Wi-Fi Hotspots, run the following command:

The output should be like this:

You can also use:

Another thing you can do is to list your network interfaces as this will be needed when you want to disconnect from a certain network:

The output should be like this:

Now when you know your WifiInterface you can easily disconnect it using the NetworkManager’s cli using the following command:

and example is:

we’re using wlan0 since this is the network interface we’re using.

In order to connect you can use:

example:

However you can also use the following commands since you can also specify the exact Wi-Fi Hotspot you’re connecting to. Have in mind that this might only work on Ubuntu 16.04 – In order to disconnect use:

nmcli c down Wi-Fi-Hotspot-name, e.g

And in order to connect to a saved Wi-Fi Hotspot use:

nmcli c up Wi-Fi-Hotspot-name, e .g

————————————————————————————————————————

This should work for you! However if you face any issues feel free to send me an email with the error/issue that you’re facing and we can check it. You can also check the full man page of the nmcli – nmcli man page if you want to check all of the options available!

You can also check – How to DISABLE DIRECTORY BROWSING IN CPANEL/WHM