Skip to content

Instantly share code, notes, and snippets.

@duclos-cavalcanti
Created August 17, 2023 18:23
Show Gist options
  • Save duclos-cavalcanti/07a35299de7e095052562ea9ef492b6d to your computer and use it in GitHub Desktop.
Save duclos-cavalcanti/07a35299de7e095052562ea9ef492b6d to your computer and use it in GitHub Desktop.
Connecting to wifi through the command line
  1. Use ip link to find the name of your wifi interface. Common names include wlan0, wlp2s0, wlx00e04c361e2, etc.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
  1. Now, knowing the wifi interface's name, scan the available WiFi networks:
iw dev <your_wifi_interface> scan
  1. Connect to WiFi:
iw dev <your_wifi_interface> connect <SSID> key <passphrase>
  1. Obtain IP Address (if needed):
dhclient <your_wifi_interface>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment