Using nmcli to create wi-fi connections.

dos2unix

Well-Known Member
Joined
May 3, 2019
Messages
3,490
Reaction score
3,224
Credits
31,265

Managing Wi-Fi Connections with nmcli in Linux​

Introduction​

nmcli is a command-line tool for managing NetworkManager, which is the default network management service in most modern Linux distributions. It allows you to create, manage, and troubleshoot network connections, including Wi-Fi. This article will guide you through using nmcli to manage Wi-Fi connections, view Wi-Fi devices using lspci and lsusb, list available SSIDs, create a Wi-Fi connection, and view the capabilities of your Wi-Fi device using iw list.

Viewing Wi-Fi Devices with lspci and lsusb​

To identify the Wi-Fi devices connected to your system, you can use the lspci and lsusb commands.

  • lspci: This command lists all PCI devices, including internal Wi-Fi adapters.
    Code:
     lspci | grep -i wireless
    This will display information about your PCI wireless adapter.
  • lsusb: This command lists all USB devices, including external Wi-Fi adapters.
    Code:
     lsusb | grep -i wireless
    This will show information about your USB wireless adapter.

Listing Available SSIDs​

To view the available Wi-Fi networks (SSIDs) within range, use the following nmcli command:
Code:
 nmcli device wifi list
This command will display a list of nearby Wi-Fi networks along with details such as SSID, signal strength, and security type.

Creating a Wi-Fi Connection​

To connect to a Wi-Fi network using nmcli, you need the SSID and the password (if applicable). Here’s how to do it:

  1. Enable your Wi-Fi device (if it’s not already enabled):
    Code:
     nmcli radio wifi on
  2. Connect to the Wi-Fi network:
    Code:
     nmcli device wifi connect "SSID" password "PASSWORD"
    Replace "SSID" with the name of the Wi-Fi network and "PASSWORD" with the network password.
  3. Create a Wi-Fi profile (optional):
    Code:
     nmcli connection add type wifi con-name "PROFILE_NAME" ifname "DEVICE_NAME" ssid "SSID"
    Replace "PROFILE_NAME" with a name for the Wi-Fi profile, "DEVICE_NAME" with the network interface name (e.g., wlan0), and "SSID" with the name of the Wi-Fi network.

Viewing Wi-Fi Device Capabilities​

To view the capabilities of your Wi-Fi device, use the iw list command:
Code:
 iw list
This command provides detailed information about your Wi-Fi device, including supported frequencies, channels, and features.

Conclusion​

Using nmcli, you can efficiently manage your Wi-Fi connections directly from the command line. Additionally, commands like lspci, lsusb, and iw list help you gather detailed information about your Wi-Fi devices and their capabilities.
 


Members online


Latest posts

Top