Ubuntu Server is a powerful server operating system. It's very much similar to Ubuntu Desktop but comes without the GUI. You interact with the system primarily via the terminal.

If you are used to connecting Ubuntu to Wi-Fi from the GUI, you might find it a bit tricky to connect to Wi-Fi from the command line. Don't worry though, here's how you can connect to Wi-Fi on Ubuntu Server.

Why Use Ubuntu Server?

Ubuntu Server is a robust operating system for handling critical systems and heavy workloads or simulating production environments.

You can install Ubuntu Server on a virtual machine (VM), laptop, desktop PC, or a dedicated server, as in most production environments.

Best of all, Ubuntu Server is open source, uses minimal system resources, and can run on old systems very well.

Step 1: Get Your Wireless Interface Name

First, you'll need to get your wireless interface name. Ubuntu uses this to configure your Wi-Fi networks. Run the following ls command to list all your network interfaces:

        ls -l /sys/class/net
    
listing network interfaces on linux

Wi-Fi interface cards start with the letter w. In this case, the Wi-Fi interface card name is wlp0s20f3. Your system will probably have a different name, so take note of that.

Step 2: Configure the Wi-Fi Network

The network configuration file on Ubuntu is a YAML file located in the /etc/netplan directory. The default name of the configuration file is 00-installer-config.yaml, and it is generated by the subiquity server installer during the installation of the OS.

Before you make changes to the configuration file, it's a good idea to create a backup. This is generally good practice when working with configuration files on Linux. Should something go wrong, you can simply revert to how things were before.

        sudo cp /etc/netplan/00-installer-config.yaml /etc/netplan/00-install-config.original.yaml
    

Now, open the network configuration file using your favorite text editor. For this guide, we'll use Vim. You'll need sudo privileges to modify the file.

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

Replace the contents of the configuration file with the following template. Make sure you change the following details:

  • Wi-Fi interface name: Replace the interface name wlp0s20f3, with the correct Wi-Fi interface name you obtained in the first step.
  • Access points: Change the access point names provided here with the correct ones. Mywifi1 and Mywifi2 are the Wi-Fi networks your server is configured to connect to by default.
  • Password: Update the password for each Wi-Fi network.
        This is the network config written by 'subiquity'

network:
 version: 2
 wifis:
   wlp0s20f3:
     access-points:
       Mywifi1:
         password: G4XJdbuBVsQeq6Rz
       Mywifi2:
         password: uRK46vdoA76iCNBY
     dhcp4: true

YAML follows strict indentation rules, so make sure you adhere to them. Use two spaces for indentations.

Save the changes you've made and close the configuration file. If you are not so familiar with Vim, here's how to save and close a file in Vim.

Step 3: Apply Your Changes

Although you have saved the changes, they aren't applied yet. You'll have to explicitly do that using the netplan utility.

Apply your changes using the following command:

        sudo netplan apply
    

Alternatively, you can reboot your system and the changes will be automatically applied once the system boots.

Alternative Method: Configuring Wi-Fi During OS Installation

An alternative to configuring Wi-Fi via the netplan configuration files is connecting to Wi-Fi during the server installation.

When you get to the Network Connection page during the installation, click the Create bond button, then follow the prompts that follow to configure your Wi-Fi interface.

configuring wifi during ubuntu server installation

Connecting to Wi-Fi From the Terminal on Ubuntu

There you have it, two ways to configure your Wi-Fi connection on Ubuntu Server. Whatever your scenario, configuring Wi-Fi on Ubuntu is very intuitive, but only if you know what to do and where to look.

On most Linux desktops, you can also use the nmcli utility to connect to Wi-Fi from the terminal.