How to Connect/Disconnect to WiFi Via Terminal
9,022
If you are using the desktop versions, the nmcli
command for Network Manager could be useful:
nmcli nm wifi [on|off]
nmcli dev wifi [list [iface <iface>] [bssid <BSSID>]]
nmcli dev wifi connect <(B)SSID> [password <password>] [wep-key-type key|phrase] [iface <iface>] [bssid <BSSID>] [name <name>] [--private] [--nowait] [--timeout <timeout>]
nmcli dev disconnect iface <iface> [--nowait] [--timeout <timeout>]
nmcli con up id <id> | uuid <id> [iface <iface>] [ap <BSSID>] [--nowait] [--timeout <timeout>]
nmcli con down id <id> | uuid <id>
In order:
- Disable and enable the WiFi.
- List available networks (specific to a wireless device and the BSSID (usually the MAC address of the AP)).
- Connect to a network, (use
password
for WPA/WPA2,wep-key-type
for WEP). - Disconnect the device and prevent it from automatically connecting again.
- Activate an existing connection. The
id
is usually the name of the file in/etc/Network-Manager/system-connections
corresponding to the connection. The UUID is available in the same file. - Deactivate an active connection.
Related videos on Youtube
Author by
user3740308
Updated on September 18, 2022Comments
-
user3740308 over 1 year
I just have a quick question that I have been researching for a while now... How do you connect/disconnect to a wifi network in ubuntu via terminal? I tried several commands that failed. I have been troubleshooting this for about 55 minutes now, and the question still continues to baffle me. FYI, I am using wlan0
Thanks Ubuntu :)
P.S. If I can provide any additional info, don't hesitate to ask.
-
hytromo over 9 yearsPlease post what you've already tried to be sure that this isn't a duplicate, aka what answers you've already tried and failed from this site?
-