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.

  • Please 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? – hytromo Aug 25 '14 at 0:01

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:

  1. Disable and enable the WiFi.
  2. List available networks (specific to a wireless device and the BSSID (usually the MAC address of the AP)).
  3. Connect to a network, (use password for WPA/WPA2, wep-key-type for WEP).
  4. Disconnect the device and prevent it from automatically connecting again.
  5. 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.
  6. Deactivate an active connection.

Not the answer you're looking for? Browse other questions tagged or ask your own question.