{"id":2624,"date":"2019-04-17T20:37:53","date_gmt":"2019-04-17T17:37:53","guid":{"rendered":"https:\/\/kifarunix.com\/?p=2624"},"modified":"2024-03-11T22:38:50","modified_gmt":"2024-03-11T19:38:50","slug":"connect-to-wifi-in-linux-using-nmcli-command","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/connect-to-wifi-in-linux-using-nmcli-command\/","title":{"rendered":"Connect to WiFi in Linux Using NMCLI command"},"content":{"rendered":"\n
This tutorial will guide you on how to connect to WiFi in Linux using NMCLI command. NMCLI is a command-line tool for controlling NetworkManager and reporting network status. It can be utilized as a replacement for nm-applet or other graphical clients. It is used to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status.<\/p>\n\n\n\n
Typical uses include:<\/p>\n\n\n\n
Want to use NETPLAN on Ubuntu 18.04 to check set static IP address? Check our previous guide by following the link below;<\/p>\n\n\n\n
How to Configure Static IP Addresses on Ubuntu 18.04 Server using Netplan<\/a><\/p>\n\n\n\n Well, before you can connect to a wireless network in Linux, you need to check if WiFi radio status.<\/p>\n\n\n\n This can be done by executing the command below;<\/p>\n\n\n\n If the WiFi radio is disabled, then you can enable it by running the command below;<\/p>\n\n\n\n You can as well check status of the network interface cards by running the command below;<\/p>\n\n\n\n NetworkManager scans Wi-Fi networks periodically. To check if the SSID of Wi-Fi access point you want to connect to can be seen your Linux system, run the command below;<\/p>\n\n\n\n If you are unable to see the SSID of the Wi-Fi access point you want to connect to, you can run a rescan by executing the command below. After that, check again to if you can see the Access point SSID by re-executing the command above.<\/p>\n\n\n\n Assuming that you already have the SSID and the connection password for the Access point you want to connect to, then execute the command below to connect.<\/p>\n\n\n\n If you do not want to display password in plain text, then you can pass the –ask<\/strong> option as shown below.<\/p>\n\n\n\n Once you have successfully connected to your AP, then you can check active connections using the command below;<\/p>\n\n\n\n You can as well omit the –active<\/strong> option to list all the connections and their status.<\/p>\n\n\n\n If you need to delete the connection that is already established, you can specify the connection UUID or the connection name. To obtain the connection UUID or the username, run the nmcli con show<\/strong> command as shown below;<\/p>\n\n\n\n To delete using a connection using connection name;<\/p>\n\n\n\n To delete a connection using connection UUID;<\/p>\n\n\n\n You can also take down or bring up a previous connection using the commands below respectively.<\/p>\n\n\n\n That is all about connecting to WiFi in Linux using NMCLI command. <\/p>\n\n\n\n Read more on:<\/p>\n\n\n\n Other Tutorials<\/p>\n\n\n\n Install and use NMCLI tool on Debian Linux<\/a><\/p>\n\n\n\n Connecting to WiFi in Linux using NMCLI command<\/h3>\n\n\n\n
Check Wi-Fi Radio Status<\/h4>\n\n\n\n
nmcli radio wifi<\/code><\/pre>\n\n\n\n
enabled<\/code><\/pre>\n\n\n\n
nmcli radio wifi on<\/code><\/pre>\n\n\n\n
nmcli dev status<\/code><\/pre>\n\n\n\n
DEVICE TYPE STATE CONNECTION \nwlp2s0 wifi disconnected -- \nenp1s0 ethernet unavailable -- \nlo loopback unmanaged -- <\/code><\/pre>\n\n\n\n
Check Available Wi-Fi Access Points<\/h4>\n\n\n\n
nmcli dev wifi list<\/code><\/pre>\n\n\n\n
SSID MODE CHAN RATE SIGNAL BARS SECURITY \nKmibey Infra 2 54 Mbit\/s 100 \u2582\u2584\u2586\u2588 WPA2 \nNcheches house Infra 1 54 Mbit\/s 37 \u2582\u2584_ <\/em>WPA2 <\/code><\/pre>\n\n\n\n
nmcli dev wifi rescan<\/code><\/pre>\n\n\n\n
Connect to WiFi using NMCLI<\/h3>\n\n\n\n
sudo nmcli dev wifi connect Kmibey password 'mypassword'<\/code><\/pre>\n\n\n\n
Device 'wlp2s0' successfully activated with 'a1900bed-baa9-47a3-affb-b640d0effe5d'.<\/code><\/pre>\n\n\n\n
sudo nmcli --ask dev wifi connect Kmibey<\/code><\/pre>\n\n\n\n
Password: ENTER PASS\nDevice 'wlp2s0' successfully activated with 'f747251b-1346-48a2-ae25-1b6fd6243984'.<\/code><\/pre>\n\n\n\n
Check Device status<\/h3>\n\n\n\n
nmcli dev status<\/code><\/pre>\n\n\n\n
DEVICE TYPE STATE CONNECTION \nwlp2s0 wifi connected Kmibey <\/strong> \nenp1s0 ethernet unavailable -- \nlo loopback unmanaged -- <\/code><\/pre>\n\n\n\n
Check Active Connections<\/h3>\n\n\n\n
nmcli con show --active<\/code><\/pre>\n\n\n\n
NAME UUID TYPE DEVICE \nKmibey a1900bed-baa9-47a3-affb-b640d0effe5d 802-11-wireless wlp2s0<\/code><\/pre>\n\n\n\n
Delete Established Connections<\/h3>\n\n\n\n
nmcli con sh<\/code><\/pre>\n\n\n\n
NAME UUID TYPE DEVICE \nKmibey 41dc9830-dd20-4deb-92be-371bfb5d16f0 802-11-wireless wlp2s0 \nBeats 949762b0-c6e0-4004-918a-55fb6bcf6610 802-11-wireless --<\/code><\/pre>\n\n\n\n
sudo nmcli con del Kmibey<\/code><\/pre>\n\n\n\n
Connection 'Kmibey' (41dc9830-dd20-4deb-92be-371bfb5d16f0) successfully deleted.<\/code><\/pre>\n\n\n\n
sudo nmcli con del 41dc9830-dd20-4deb-92be-371bfb5d16f0<\/code><\/pre>\n\n\n\n
Connection 'Kmibey' (41dc9830-dd20-4deb-92be-371bfb5d16f0) successfully deleted.<\/code><\/pre>\n\n\n\n
nmcli con down <SSID or UUID><\/code><\/pre>\n\n\n\n
nmcli con up <SSID or UUID><\/code><\/pre>\n\n\n\n
man nmcli<\/a><\/code><\/pre>\n\n\n\n
man nmcli-examples<\/code><\/pre>\n\n\n\n