[Ubuntu] Linux uses the nmcli command to connect to the Wi-Fi network

In Linux systems, you can use nmclicommands to connect to Wi-Fi networks. nmcliis NetworkManager's command-line tool for managing network connections.

Here are nmclithe steps to connect to a Wi-Fi network via commands:

  1. Open Terminal: You can use the Ctrl+Alt+T shortcut to open Terminal, or find Terminal through the Applications menu.

  2. Scan for available Wi-Fi networks: Run the following command to scan for available Wi-Fi networks:

    nmcli device wifi rescan && nmcli device wifi list

    The first line of command is to re-scan for available Wi-Fi networks, and the second line of command is to list the scan results. You will see a list of available Wi-Fi networks and their related information, such as SSID (network name), MODE (mode), CHAN (channel), RATE (speed), etc.

  3. Connect to a Wi-Fi network: According to the scan result, select the Wi-Fi network you want to connect to, and run the following command to connect to it:

    nmcli device wifi connect <SSID> password <password>

    will <SSID>be replaced by the SSID (name) of the Wi-Fi network you want to connect to, and <password>replaced by the password for that network.

    For example, if you want to connect to a Wi-Fi network named "MyWiFi" with a password of "mypassword", the command would be as follows:

    nmcli device wifi connect MyWiFi password mypassword

    If the connection is successful, the terminal will display information about the connection.

  4. Verify Connection: Run the following command to verify the connection was successful:

    nmcli connection show

    This will display information for all network connections, including connected Wi-Fi networks.

Hope this helps you nmcliconnect to Wi-Fi network in Linux system with commands! If you have any other questions, please feel free to ask.

Guess you like

Origin blog.csdn.net/Holenxr/article/details/131733843