Ubuntu 20.04: Connect to wifi from command line - LinuxConfig.org

In this tutorial you will learn how to connect to WiFi from command line using Netplan. This could be useful if you are running a headless Ubuntu 20.04 system such as server or Ubuntu 20.04 on Raspberry Pi.
This is a companion discussion topic for the original entry at https://linuxconfig.org/ubuntu-20-04-connect-to-wifi-from-command-line

for my raspberry pi 4, I tried this and ran into error.
after a bit troubleshooting/searching I found there’s a missing step:
after config update, need to first run
sudo netplan generate
sudo netplan apply

1 Like

It seems that this solution of “hardcoding” the wireless SSID has just solved my Ubuntu 20.04 suspend problem, where the wireless would not reconnect whatsoever when starting up from from the suspended state.

Thanks, that save me a lot of annoying restarts when I still have a lot of programs open and I need to suspend my laptop.

If a computer is connected simultaneously to a WiFi and Ethernet, it prioritizes Ethernet for internet access. Can I prioritize the WiFi for internet access with netplan?

Using the guide above netplan was configured properly but the underlaying system fails because
‘Ubuntu server 20.04’ does not include wpasupplicant (which is only 1.4Mb),

Connect an ethernet cable and restart computer then:

# run as su
apt install wpasupplicant
netplan apply

# might need to do this as well
systemctl daemon-reload

This solution was found on askubuntu, it was posted by nerkn

another gotcha: Trying to connect to a 5ghz router when my server only has 2.4Ghz support