How To Connect To WiFi Via Terminal

Amogh | Oct 25, 2024

Do you remember the meme, which goes, “I’m connecting to my WiFi using terminal, my friends…HACKER”? I have never seen anyone doing that in real life. But nowadays I have a strong reason to do that in the presence or absence of my friends.

For some strange reason, my desktop environments keep breaking the much needed nm-applet. For those who may not know, generally speaking, nm-applet is the WiFi icon that you see on the top or bottom right of your screen; when clicked shows the WiFi networks available nearby. Imagine how frustrating it would be to suddenly not see it!

Before jumping into the hacky stuff, let me tell you some fixes if it happens. You restart your machine. If it doesn’t bring back nm-applet, try again. Don’t let the third time taunt you, instead fire up your terminal and become a hacker!

List the Networks

nmcli dev wifi list

This will list all the networks that are available.

Connect To The Network

nmcli dev wifi connect "SSID_NAME" password "Your password"

SSID_NAME (no quotes) is the name of the WiFi network you need to connect to (for example,“My WiFi”) and password is the part of the command; don’t get confused; afterpassword type the actual password of the WiFi network by replacing “Your password” (no quotes).

nmcli dev wifi connect "SSID_NAME"

Once you connect with the password, next time you don’t need to add the password.

Tip 1: If you often face this problem like I do, you don’t need to type these commands every time; use Ctrl + R to reverse search in the Linux Terminal.

Tip 2: Add the connection command to a shell script and execute it whenever you face the problem.