Setup and Configuration

How to Connect Wifi Ubuntu? Terminal Command Tips

Introduction Ubuntu is one of the most popular Linux distributions for desktops, laptops, and servers. Whether you are installing Ubuntu for the first time or managing a headless server, knowing How to Connect Wifi Ubuntu? is an essential skill. While the grap

HowToFixWiFi

Introduction

Ubuntu is one of the most popular Linux distributions for desktops, laptops, and servers. Whether you are installing Ubuntu for the first time or managing a headless server, knowing How to Connect Wifi Ubuntu? is an essential skill. While the graphical desktop makes it easy to click and connect, there are many situations where the terminal is faster, more reliable, or simply the only option available.

This guide walks you through every practical method for connecting Ubuntu to a wireless network. You will learn how to use the NetworkManager command-line interface (nmcli), the text-based user interface (nmtui), and lower-level tools such as iw and wpa_supplicant. We also cover troubleshooting, connection management, and best practices so your WiFi stays stable after you connect.

If you have ever asked yourself How to Connect Wifi Ubuntu? without using a mouse, this article is for you. Let us begin with what you need before you start.

Table of Contents

Prerequisites: What You Need Before Starting

Before you attempt How to Connect Wifi Ubuntu?, make sure the following items are in place. Skipping these basics is the most common reason for connection failures.

  • A working wireless adapter: Your computer must have an internal WiFi card or a compatible USB wireless dongle. Ubuntu supports most modern adapters, but some require proprietary drivers.
  • The network name (SSID): You need to know exactly what the wireless network is called. Remember that SSIDs are case-sensitive.
  • The WiFi password: If the network is secured, have the passphrase ready. For WPA2 or WPA3 networks, this is usually a long string of characters.
  • Administrator access: Most WiFi commands require sudo privileges because they modify system network settings.
  • Terminal access: You should be able to open a terminal window. On Ubuntu Desktop, press Ctrl + Alt + T. On Ubuntu Server, you are already in a terminal.
  • NetworkManager installed: Most Ubuntu desktop editions include NetworkManager by default. If you are on a minimal server installation, you may need to install it first.

Once you have confirmed these requirements, you are ready to choose a connection method and proceed.

Understanding Ubuntu WiFi Tools: nmcli, nmtui, and iw

Ubuntu provides several ways to manage wireless connections from the command line. Understanding the difference between them will help you answer How to Connect Wifi Ubuntu? in the right context.

nmcli (NetworkManager Command Line Interface)

nmcli is the official command-line tool for NetworkManager. It is the recommended method for most Ubuntu users because it works on both desktop and server editions, supports all common security types, and integrates with the system’s network configuration.

nmtui (NetworkManager Text User Interface)

nmtui provides a menu-driven interface inside the terminal. It is ideal if you prefer not to memorize commands but do not have a graphical desktop. You navigate with arrow keys and make selections with Enter.

iw and wpa_supplicant

iw is a lower-level utility for configuring wireless devices. It is often used for scanning and debugging. wpa_supplicant handles the actual authentication for WPA and WPA2 networks. These tools are more advanced and are usually reserved for minimal installations or custom scripts.

For everyday use, start with nmcli or nmtui. Reserve iw and wpa_supplicant for troubleshooting or specialized environments.

How to Connect Wifi Ubuntu? Using the Desktop GUI

If you are using Ubuntu Desktop with a graphical interface, the easiest way to connect is through the Settings application. This method does not require the terminal, but it is useful to know as a baseline.

  1. Click the system menu in the top-right corner and select Settings, or open Settings from the application grid.
  2. In the left sidebar, click WiFi.
  3. Toggle the WiFi switch to On.
  4. Wait for the list of available networks to appear.
  5. Click the name of the network you want to join.
  6. Enter the password when prompted and click Connect.
  7. Once connected, the WiFi icon in the top bar will show signal strength.

While the GUI is convenient, it is not available on Ubuntu Server or when you are working over SSH. That is where terminal commands become necessary for How to Connect Wifi Ubuntu?

How to Connect Wifi Ubuntu? Using nmcli in the Terminal

nmcli is the most powerful and flexible way to answer How to Connect Wifi Ubuntu? from the terminal. Follow these steps carefully.

Step 1: Check Your Wireless Device

First, confirm that Ubuntu sees your wireless adapter.

nmcli device status

Look for a device with wifi in the TYPE column. It might be named wlan0, wlp2s0, or something similar. The STATE column should show disconnected or unavailable. If you see unavailable, the WiFi may be hard-blocked or the driver may be missing.

Step 2: List Available WiFi Networks

Scan for nearby wireless networks so you can confirm the exact SSID.

nmcli device wifi list

The output will show network names, signal strength, security type, and whether the network is active. Copy the SSID exactly as it appears.

Step 3: Connect to a WiFi Network

Use the following syntax to connect. Replace YOUR_SSID with your network name and YOUR_PASSWORD with your WiFi passphrase.

nmcli device wifi connect "YOUR_SSID" password "YOUR_PASSWORD"

If the connection succeeds, nmcli will report that the device has been activated and an IP address has been assigned.

Step 4: Verify the Connection

Check that the device is now connected:

nmcli device status

You should see your wireless device in the connected state. You can also test internet access with:

ping -c 4 google.com

Connecting to a Hidden Network with nmcli

Hidden networks do not broadcast their SSID. To connect, add the hidden yes option:

nmcli device wifi connect "HIDDEN_SSID" password "YOUR_PASSWORD" hidden yes

This tells NetworkManager to probe for the specific network even though it is not broadcasting.

How to Connect Wifi Ubuntu? Using nmtui (Text User Interface)

nmtui is a great middle ground if you want a visual menu without installing a desktop environment. It is especially helpful for users who are new to the terminal but still want to learn How to Connect Wifi Ubuntu? without typing complex commands.

  1. Open a terminal and type:
nmtui
  1. A blue menu screen will appear. Use the arrow keys to highlight Activate a connection and press Enter.
  2. You will see a list of available WiFi networks. Highlight your network and press Enter.
  3. If the network is secured, enter the password when prompted.
  4. Select Activate to establish the connection.
  5. Choose Back to return to the main menu, then select Quit to exit.

nmtui writes the connection to NetworkManager, so the network will be remembered for future boots. You can also use nmtui edit to modify existing connections or nmtui hostname to change your system hostname.

How to Connect Wifi Ubuntu? Using iw and wpa_supplicant

On minimal Ubuntu installations, NetworkManager may not be running. In those cases, you can use iw for scanning and wpa_supplicant for authentication. This method is more manual but gives you full control.

Scanning for Networks with iw

First, identify your wireless interface name:

iw dev

Look for a line such as Interface wlan0. Then scan for networks:

sudo iw dev wlan0 scan | grep SSID

Replace wlan0 with your actual interface name. This command prints the names of nearby access points.

Creating a wpa_supplicant Configuration

For WPA2-Personal networks, create a configuration file. A common location is /etc/wpa_supplicant/wpa_supplicant.conf.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add the following content:

network={
    ssid="YOUR_SSID"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
}

Save and exit. Then start wpa_supplicant in the background:

sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

Finally, obtain an IP address using DHCP:

sudo dhclient wlan0

This approach is common on Ubuntu Server or embedded devices where you want a lightweight network stack.

Connecting to Hidden WiFi Networks

Hidden networks require you to know the SSID in advance because they do not appear in scan results. With nmcli, use the hidden yes flag as shown earlier. With wpa_supplicant, add scan_ssid=1 to the network block:

network={
    ssid="HIDDEN_SSID"
    psk="YOUR_PASSWORD"
    key_mgmt=WPA-PSK
    scan_ssid=1
}

This forces wpa_supplicant to actively probe for the hidden network instead of waiting for it to broadcast.

Troubleshooting Common WiFi Connection Issues on Ubuntu

Even when you know How to Connect Wifi Ubuntu?, things can go wrong. Here are the most frequent problems and how to fix them.

WiFi Adapter Is Blocked

Ubuntu may soft-block or hard-block your wireless radio. Check the status with:

rfkill list

If you see Soft blocked: yes, unblock it:

sudo rfkill unblock wifi

If it says Hard blocked: yes, look for a physical switch or function key on your laptop that enables WiFi.

Authentication Failure

Double-check the password. Remember that WiFi passwords are case-sensitive. If you recently changed the router password, delete the saved connection in Ubuntu and reconnect from scratch.

Connected but No Internet

Sometimes Ubuntu connects to the router but cannot resolve domain names. Test with an IP address:

ping -c 4 8.8.8.8

If that works but ping google.com fails, you have a DNS issue. You can set Google DNS temporarily:

nmcli connection modify "YOUR_CONNECTION_NAME" ipv4.dns "8.8.8.8 8.8.4.4"

Then reactivate the connection:

nmcli connection down "YOUR_CONNECTION_NAME"
nmcli connection up "YOUR_CONNECTION_NAME"

NetworkManager Is Not Running

On server installations, NetworkManager may not be active. Start and enable it:

sudo systemctl start NetworkManager
sudo systemctl enable NetworkManager

WiFi Disconnects After Idle Time

Ubuntu may put the wireless card into power-saving mode. Disable it with:

sudo iwconfig wlan0 power off

Note that this setting may reset after a reboot. For a permanent fix, create a systemd service or modify NetworkManager’s WiFi power-save configuration.

Saving and Managing WiFi Connections on Ubuntu

Once you know How to Connect Wifi Ubuntu?, you will likely want to manage those connections later. NetworkManager stores every saved wireless profile.

List All Saved Connections

nmcli connection show

This displays every wired, wireless, and VPN profile known to the system.

Bring a Saved Connection Up

To reconnect to a known network without scanning again:

nmcli connection up "CONNECTION_NAME"

Modify a Saved Connection

Change the password or other settings:

nmcli connection modify "CONNECTION_NAME" wifi.ssid "NEW_SSID"
nmcli connection modify "CONNECTION_NAME" wifi-sec.psk "NEW_PASSWORD"

Delete or Forget a Network

Remove a profile so Ubuntu will not connect to it automatically:

nmcli connection delete "CONNECTION_NAME"

Saved connections are also stored as files under /etc/NetworkManager/system-connections/. You can back up this directory before reinstalling Ubuntu to preserve your WiFi profiles.

How to Connect Wifi Ubuntu? On Ubuntu Server Without a GUI

Ubuntu Server does not include a desktop environment, so there is no Settings menu to click. You must rely on the terminal. There are two common approaches.

Using NetworkManager on Ubuntu Server

If NetworkManager is installed, the nmcli steps described earlier work exactly the same. Install it if needed:

sudo apt update
sudo apt install network-manager

Then use nmcli device wifi list and nmcli device wifi connect as shown above.

Using netplan for WiFi

Ubuntu Server traditionally uses netplan for network configuration. While netplan is primarily designed for wired networks, recent versions support WiFi through the wifis renderer.

Edit your netplan YAML file, usually located at /etc/netplan/00-installer-config.yaml or /etc/netplan/01-netcfg.yaml:

sudo nano /etc/netplan/00-installer-config.yaml

Add a WiFi configuration block:

network:
  version: 2
  wifis:
    wlan0:
      dhcp4: true
      access-points:
        "YOUR_SSID":
          password: "YOUR_PASSWORD"

Apply the changes:

sudo netplan apply

If you encounter errors, run sudo netplan try first, which rolls back automatically if you lose connectivity.

Tips and Best Practices for Stable WiFi on Ubuntu

Connecting is only the first step. Keeping your connection stable requires a few good habits.

  • Keep Ubuntu updated: Run sudo apt update && sudo apt upgrade regularly to receive driver and firmware fixes.
  • Use 5 GHz when available: If your router supports both 2.4 GHz and 5 GHz, connect to the 5 GHz band for less interference and faster speeds.
  • Disable WiFi power saving on desktops: If you experience random disconnects, turn off power management as shown in the troubleshooting section.
  • Save your connection profiles: Back up /etc/NetworkManager/system-connections/ so you do not have to re-enter passwords after a reinstall.
  • Use a VPN on public WiFi: Ubuntu does not encrypt your traffic beyond the router. A VPN adds privacy on open networks.
  • Document hidden SSIDs: Hidden networks are harder to troubleshoot. Keep a secure note of the SSID and password.
  • Check router compatibility: Some older routers only support WPA2, while newer ones may default to WPA3. Ensure your Ubuntu version and wireless driver support the security standard in use.

Comparison Table: WiFi Connection Methods on Ubuntu

The table below compares the main ways to answer How to Connect Wifi Ubuntu? so you can choose the right one for your situation.

Method Interface Best For Pros Cons
Desktop GUI Graphical Ubuntu Desktop beginners Easy, visual, no commands needed Not available on server or SSH sessions
nmcli Terminal Most Ubuntu users Fast, scriptable, works on desktop and server Requires remembering command syntax
nmtui Terminal menu Users who prefer menus Visual inside terminal, easier than nmcli Slower for automation, fewer advanced options
iw + wpa_supplicant Terminal Minimal installations, advanced users Low-level control, lightweight Manual setup, no automatic reconnection by default
netplan YAML config Ubuntu Server, cloud instances Declarative, version-controlled config WiFi support is more limited than nmcli

Frequently Asked Questions

Can I connect to WiFi on Ubuntu without a password?

Yes. Open networks do not require a password. With nmcli, simply omit the password option:

nmcli device wifi connect "OPEN_NETWORK"

However, open networks are insecure. Avoid sending sensitive data over them unless you use a VPN.

Why is the nmcli command not found?

This usually means NetworkManager is not installed. Install it with:

sudo apt update
sudo apt install network-manager

How do I forget a WiFi network on Ubuntu?

Use nmcli connection delete "CONNECTION_NAME". Replace CONNECTION_NAME with the name shown in nmcli connection show.

Does Ubuntu support WPA3?

Yes, recent versions of Ubuntu support WPA3 through NetworkManager and wpa_supplicant. Both your router and your wireless adapter must also support WPA3.

Can I connect to WiFi from the Ubuntu installer?

Yes. During installation, Ubuntu detects wireless adapters and lets you select a network. If you skip this step, you can configure WiFi after installation using any method in this guide.

What should I do if my WiFi adapter is not detected?

Run lspci or lsusb to see if the hardware appears. If it does, you may need to install proprietary drivers through Software & Updates or ubuntu-drivers autoinstall.

Conclusion

Knowing How to Connect Wifi Ubuntu? is a fundamental skill for every Ubuntu user. Whether you prefer the simplicity of the desktop GUI, the speed of nmcli, the menu-driven convenience of nmtui, or the low-level control of iw and wpa_supplicant, you now have multiple reliable options.

Start with nmcli for most daily tasks. Use nmtui when you want a visual terminal menu. Reserve iw and wpa_supplicant for advanced troubleshooting or minimal server setups. Always keep your system updated, back up your connection profiles, and follow the best practices outlined here to maintain a stable wireless connection.

If you run into issues, refer back to the troubleshooting section and the comparison table to choose the right tool. With these commands and tips, you can get any Ubuntu machine online quickly and confidently.