unscripted. home blog

WIFI in the cli with iwctl

4/29/2025

A little article about setting up a WIFI connection in the cli with iwctl.

Sometimes you don’t have access to a GUI network manager, potentially just after installing a new distribution or a system without a graphic interface.
That should not stop you from connecting to WIFI, and it is not that hard as it seems.

What is iwctl and why ?

iwctl is actually a cli to control (ctl) a wifi daemon called iwd.
The cli provides everything you need to connect to every WIFI network out there.
IMHO, iwctl is the most straightforward tool to use WIFI on your Linux machine.

How to get it ?

Check for a package named iwd in your Linux distribution, that should be available for different Linux/Architectures.

Do I even have a WIFI card (device) on my machine ?

Before trying to connect to a WIFI network, you must have at least one wifi device on your machine.
Let’s check this.
With iwctl, you can enter an interactive mode by just using iwctl without parameters, that’s what I will do for the next commands.

$ iwctl
NetworkConfigurationEnabled: enabled
StateDirectory: /var/lib/iwd
Version: 3.6
[iwd]# 

You have the same output as me ? Ok let’s go.
To list available devices, use station list

Shows the station list command

Here you can see that I have 1 device named wlan0, in station mode and connected.

What’s a station and the station mode ?

A station is a device that can connect to WIFI (a client).
So station mode for a wireless device, is a mode where it can connect to wireless networks.
That’s what we are looking for !

List available networks

Now that we have our WIFI device ready, let’s check for available networks.
Replace wlan0 by the name of your device.

[iwd]# station wlan0 scan

Now let’s list the networks found.

[iwd]# station wlan0 get-networks

Shows the get-networks command

As you can see, I’m connected to Livebox-1450.
I created another access point (AP) called Wifitmp, let’s connect to it.

Connect to a network

[iwd]# station wlan0 connect Wifitmp

Shows the connect command

iwctl is asking me the passphrase as the network is protected via psk (pre-shared key).
And that’s it ! We should be connected to the network, with internet access if there is a configured gateway.
You can check the status of your connection with

[iwd]# station wlan0 show

Shows the station details

Note that you don’t have to scan everytime to get the networks, there is a known-networks list you can check with

[iwd]# known-networks list

Pretty simple right ?

Disconnect from a network

Now you want to be focused and not disturbed by external notifications, emails…
Let’s disconnect.

[iwd]# station wlan0 disconnect

I think that’s all for the basic needs of anyone wanting to interact with WIFI networks.
iwctl provides other commands, to deal with WPS or WSC and other modes.