The purpose of this tutorial is to connect to a WiFi network via the command line on Ubuntu 22.04 Jammy Jellyfish.
This could be useful if you are running a headless Ubuntu 22.04 system such as server or Ubuntu 22.04 on Raspberry Pi. Connecting from command line is done through configuration of Netplan on Ubuntu. Follow the step by step instructions below to see how.
In this tutorial you will learn:
- How to identify the name of your wireless network interface
- How to configure Netplan to connect to wireless network (SSID)

Category | Requirements, Conventions or Software Version Used |
---|---|
System | Ubuntu 22.04 Jammy Jellyfish |
Software | Netplan (installed by default) |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Ubuntu 22.04: Connect to WiFi from command line with Netplan step by step instructions
- First step is to open a command line terminal and identify the name of your wireless network interface. To do so execute:
$ ls /sys/class/net enp0s25 lo wlp3s0
Depending on your Ubuntu 22.04 system the wireless network interface name would be something like:
wlan0
or like in this case it iswlp3s0
. - Next, navigate to the
/etc/netplan
directory and locate the appropriate Netplan configuration files. The configuration file might have a name such as01-network-manager-all.yaml
or50-cloud-init.yaml
.$ ls /etc/netplan/
- Edit the Netplan configuration file with nano or your favorite text editor. You will have to open the file with root permissions.
$ sudo nano /etc/netplan/50-cloud-init.yaml
- Copy and paste the following configuration stanza while replacing the
SSID-NAME-HERE
andPASSWORD-HERE
text with your SSID network name and password:wifis: wlan0: optional: true access-points: "SSID-NAME-HERE": password: "PASSWORD-HERE" dhcp4: true
Make sure that the
wifis
block is aligned with the aboveethernets
orversion
block if present. The entire configuration file may look similar to the one below:# This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: eth0: dhcp4: true optional: true version: 2 wifis: wlp3s0: optional: true access-points: "SSID-NAME-HERE": password: "PASSWORD-HERE" dhcp4: true
Alternatively, you may also wish to configure a static IP address to your wireless interface.
- Once ready, apply the changes and connect to your wireless interface by executing the bellow command:
$ sudo netplan apply
Alternatively, if you run into some issues execute:
$ sudo netplan --debug apply
- If all went well you would be able to see your wireless adapter connected to the wireless network by executing the
ip
command:$ ip a
Closing Thoughts
In this tutorial, we saw how to connect to a WiFi network via the command line on Ubuntu 22.04 Jammy Jellyfish Linux. This is done through editing the Netplan configuration files, and is mostly useful on headless systems such as a server or Raspberry Pi, which doesn’t have a GUI installed.