Using CLI to manage wireless (WiFi) device on Ubuntu 18.04
Posted on
The building I stay in has a lot of people working remotely from their homes. It is hard to find a WiFi signal that isn't overlapping for the 2.4 GHz band. Even with a fast internet connection, I was facing network instability.
The 5 GHz signal wasn't very strong with the room door closed. This was required since my son is less than two and is very interested on what does his papa do all day.
Realizing that it may be another year of working from home, I ended up setting up a wired LAN. While my network issues with video calls got sorted, I did end up learning a thing or two on how to manage Wireless networking for Ubuntu from the command line.
Most of what I am sharing is by extensive Googling. DuckDuckGoing and reading StackOverflow and Ask Ubuntu. Amazing communities for all kinds of Linux users.
List network interfaces
nmcli device
nmcli d #Shorter version with same result
Connecting and diconnecting WiFi using nm-cli
Figure out your WiFi interface using the previous command. It usually starts with wlp
in Ubuntu
nmcli device disconnect wlps0
nmcli d connect wlps0
Best part is the auto-complete supported by nmcli
using which you can even complete the interface names.
Enabling and Disabling the WiFi radio
nmcli radio wifi off
nmcli r wifi on # r is a short for radio
I disable the Wifi radio when connected to the LAN. But if I use the laptop away from my desk, I enable the radio and connect to my pre-configured Wireless just with a bit of command line.