How to Connect to WiFi from the Command Line on Fedora (nmcli)

Connect to Wi-Fi on Fedora using nmcli commands to scan, join, and auto-connect to your network.

You need WiFi and the GUI is gone

You are sitting in front of a Fedora machine with no monitor attached, or your SSH session just dropped because the network interface went down. The desktop environment is inaccessible, and you need to get back on the network fast. Maybe you are provisioning a new server in a data center and the only way to configure the wireless adapter is through the terminal. You need to scan for networks, connect to one, and make sure the connection sticks after a reboot, all without touching a mouse.

How NetworkManager manages WiFi

NetworkManager is the daemon that handles network configuration on Fedora. It manages interfaces, connections, and profiles. nmcli is the command-line interface to NetworkManager. It talks to the daemon via D-Bus. When you run nmcli, you are not directly configuring the kernel interface. You are telling NetworkManager to create or modify a connection profile, and NetworkManager applies that profile to the hardware.

This separation is the core design. The profile lives in /etc/NetworkManager/system-connections/. The hardware state is transient. If you edit files in that directory directly, NetworkManager might overwrite them or refuse to load them due to permission errors. Always use nmcli or nmtui to manage profiles.

nmcli commands fall into two categories. device commands interact with the hardware state. connection commands interact with the stored profiles. Think of device as the radio hardware and connection as the station presets. You scan with the device, but you save and recall settings with the connection.

Scan for available networks

Run the scan command to see what access points are visible.

nmcli device wifi list
# WHY: Queries the active WiFi device for available access points.
# Returns a table with SSID, mode, channel, rate, signal, security, and BSSID.

The output shows the SSID, the signal strength in dBm, and the security type. A signal strength of -40 dBm is excellent. A signal below -70 dBm often causes intermittent drops that look like application errors. Check the signal column before connecting. A weak signal causes drops that are hard to debug later.

If the list is empty, the device might be blocked. Check the rfkill state.

rfkill list
# WHY: Shows hardware and software block states for all wireless devices.
# Look for "Soft blocked: yes" or "Hard blocked: yes".

If the device is soft blocked, unblock it.

rfkill unblock wifi
# WHY: Clears the software block.
# NetworkManager can now use the device.

If the device is hard blocked, you need to press a physical switch or a key combination on your laptop. No command can override a hardware switch.

Connect to a network

Once you have the SSID, connect to the network. The device wifi connect command creates a new profile and activates it in one step.

nmcli device wifi connect "MyNetwork" password "MySecretPassword"
# WHY: Creates a connection profile named "MyNetwork" and activates it immediately.
# NetworkManager handles authentication, key exchange, and DHCP negotiation.

NetworkManager is case-sensitive. Use the exact SSID from the scan output. If the SSID contains spaces, wrap it in quotes. If the connection succeeds, nmcli prints Connection successfully activated.

By default, nmcli device wifi connect sets connection.autoconnect to yes. The connection will persist across reboots. If you need to verify or change this setting, use the connection modify command.

nmcli connection modify "MyNetwork" connection.autoconnect yes
# WHY: Ensures the connection profile activates automatically when the interface comes up.
# Without this, you must manually activate the connection after every reboot.

NetworkManager creates the profile file in /etc/NetworkManager/system-connections/. Do not edit these files manually. Use nmcli connection modify to change settings. Direct file edits cause permission drift and break NetworkManager.

Verify the connection

Confirm the device is connected and has an IP address.

nmcli device status
# WHY: Shows the state of all network devices.
# Look for "connected" under the STATE column for your WiFi device.

Check the active connection profile.

nmcli connection show --active
# WHY: Lists only the currently active connection profiles.
# Confirms NetworkManager has bound the profile to the device.

Test internet connectivity.

ping -c 4 1.1.1.1
# WHY: Sends four ICMP echo requests to a public DNS server.
# Success proves the network stack, routing, and DNS are functional.

Run ping -c 4 1.1.1.1. If the ping succeeds, your network stack is functional. If it fails, check the IP address with ip addr and review the logs.

Manage connection profiles

You can inspect, modify, and remove profiles. Inspect a profile to see all settings.

nmcli connection show "MyNetwork"
# WHY: Displays all properties of the connection profile.
# Includes IPv4/IPv6 settings, DNS, proxy, and security parameters.

To change a setting, use connection modify. For example, to force DHCPv4.

nmcli connection modify "MyNetwork" ipv4.method auto
# WHY: Sets IPv4 configuration to DHCP.
# Use "manual" if you need a static IP address.

To remove a profile.

nmcli connection delete "MyNetwork"
# WHY: Removes the profile from storage and deactivates it if active.
# The file in /etc/NetworkManager/system-connections/ is deleted.

Use nmcli connection modify to change settings. Direct file edits cause permission drift and break NetworkManager.

Common pitfalls and error messages

Error: Connection activation failed: No suitable device found.

This error means NetworkManager cannot find a device that matches the profile type. The profile might be for WiFi, but the device is disconnected or blocked.

nmcli device status
# WHY: Verifies the device exists and is in the "disconnected" or "connected" state.
# If the device is missing, check `dmesg` for driver issues.

Error: Connection activation failed: The connection is not available on the device.

This error occurs when the device is unmanaged. NetworkManager ignores the device.

nmcli device set wlp2s0 managed yes
# WHY: Forces NetworkManager to manage the device.
# Replace wlp2s0 with your actual device name.

Hidden SSID.

If the access point does not broadcast the SSID, you must specify hidden yes.

nmcli device wifi connect "HiddenSSID" hidden yes password "MySecretPassword"
# WHY: Tells NetworkManager to probe for the SSID instead of waiting for beacons.
# Hidden networks consume more power and take longer to connect.

WPA3 vs WPA2.

Fedora defaults to WPA3-SAE where available. If the access point only supports WPA2, nmcli usually handles the fallback. If you need to force WPA2.

nmcli connection modify "MyNetwork" 802-11-wireless-security.key-mgmt wpa-psk
# WHY: Forces WPA2-PSK authentication.
# Use this only if the access point does not support WPA3-SAE.

Check rfkill list before debugging software. A hardware switch is the silent killer of WiFi connectivity.

When to use nmcli versus other tools

Use nmcli when you are scripting network configuration or working in a headless environment without a TUI. Use nmtui when you prefer a text-based menu interface and want to avoid typing long command strings. Use the GUI network settings when you are on a desktop and need to visualize connection strength or manage complex VPN profiles visually. Use wpa_supplicant directly only when you are debugging low-level authentication failures and need to bypass NetworkManager entirely.

Trust nmcli for automation. Use nmtui for interactive configuration. Avoid manual config files.

Where to go next