Setting up the wireless interface on Ubuntu Linux is likely one of the first things you’ll need to do after installing the operating system and booting into it for the first time. As long as you have the proper hardware, Ubuntu can easily connect to Wi-Fi networks configured with various types of security like WEP, WPA, and WPA2.
In this guide, we will cover the step by step instructions to connect to a Wi-Fi network from the GNOME GUI (the default desktop environment) on Ubuntu. We will also show how to connect to Wi-Fi from command line, which is handy in the case of headless servers or those running without a desktop environment. Follow along with us below to find out how.
In this tutorial you will learn:
- How to connect to Wi-Fi network in GNOME GUI
- How to connect to Wi-Fi network via command line
- How to enable or disable the system’s Wi-Fi adapter
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Ubuntu Linux |
Software | N/A |
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 |
Connect to Wi-Fi network from GNOME GUI
You can follow the steps below to learn how to connect to a Wi-Fi network from GUI. These instructions are for GNOME in particular, the default desktop environment on Ubuntu and many other Linux systems. However, all desktop environments should have very similar steps.
- To connect to a Wi-Fi network, get started by clicking on the upper right corner, on the GNOME menu, and expand the Wi-Fi option. Then, click on “select network.”
- Next, highlight the Wi-Fi network you wish to connect to, then click “connect.”
- As long as the Wi-Fi is secure, it will prompt you for a password to connect. Enter the network key and then click connect.
- To view more information about the network you’ve just connected to, click on the “Wi-Fi settings” option.
- Then, click on the configuration icon next to your network’s name (SSID).
- In this menu, you can see information about your local IPv4 and IPv6 address, default gateway, DNS, etc. You can also click “forget connection” if you wish to remove this network from the list of known Wi-Fi networks, or poke around the other menus for more configuration.
- Note that you can quickly turn your Wi-Fi interface on or off at any time under the GNOME network menu in the upper right corner. This is sometimes a basic troubleshooting step if you are having connectivity issues.
Connect to Wi-Fi network via command line
If connecting to a Wi-Fi network from GUI isn’t an option for you, as would be the case of a headless server, you can also use the command line to connect to a Wi-Fi network on Ubuntu. Follow the steps below to find out how.
- The first thing we need to do is identify the name of our Wi-Fi adapter. Common names on Ubuntu include
wlan0
orwlp3s0
. Execute the following command to find yours.$ ls /sys/class/net enp0s25 lo wlp3s0
The first adapter listed is our ethernet connection, then the loopback interface, then
wlp3s0
, which is our Wi-Fi adapter. - 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:
$ sudoedit /etc/netplan/50-cloud-init.yaml
and insert the following configuration stanza while replacing the
SSID-NAME-HERE
andPASSWORD-HERE
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
- 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
- If at any time you need to disable or enable the Wi-Fi adapter, use the following
ip
commands. Sometimes turning the interface off and back on can be a basic troubleshooting step.$ sudo ip link set dev wlp3s0 down AND/OR $ sudo ip link set dev wlp3s0 up
Closing Thoughts
In this guide, we saw how to setup the wireless interface on an Ubuntu Linux system by connecting to Wi-Fi networks via GNOME GUI and command line. We also learned how to enable or disable the system’s Wi-Fi adapter. Following these steps should get you connected to the local network and internet in a matter of seconds, whether you are on a desktop system or headless server.