Skip to content

Linux WLAN connection via terminal

Method 1

The nmcli tool is the terminal version of NetworkManager. Type in Çımcli help for more info.

To turn on your wireless card, type in:

nmcli radio wifi on

To turn it off, type in:

nmcli radio wifi off

Method 2

1. Find name of wireless card

iwconfig

2. Turn on wireless card

sudo ifconfig wlan0 up

3. Connect to network

3.1 WEP network

Set SSID and password:

sudo iwconfig wlan0 essid WIFI_NETWORK_HERE key PASSWORD_HERE

Note: The password in the command iwconfig wlan0 essid name key password should be in hexadecimal. If you want to type the ASCII password, you would use iwconfig wlan0 essid name key s:password.

Obtain an IP address and connect to the WiFi network:

sudo dhclient wlan0

3.2 WPA or WPA2 network

iw (list/config) can only handle WEP. If the access point uses WPA/WPA2, you'll have to use another method to connect.

You need the wpasupplicant package which provides the wpa_supplicant command, install if necessary through sudo apt-get install wpasupplicant.

You put your SSID and password into /etc/wpa_supplicant.conf (requires sudo):

network={
    ssid="ssid_name"
    psk="password"
}

Assuming your interface is wlan0 you can connect with:

sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf -D wext
sudo dhclient wlan0

"wext" is a driver and that will be specific for each card; refer to wpa_supplicant -h.

Examples:
- hostap (default) Host AP driver (Intersil Prism2/2.5/3). (this can also be used with Linuxant DriverLoader) - hermes Agere Systems Inc. driver (Hermes-I/Hermes-II) - madwifi MADWIFI 802.11 support (Atheros, etc.) - atmel ATMEL AT76C5XXx (USB, PCMCIA) - wext Linux wireless extensions (generic) - ndiswrapper Linux ndiswrapper - broadcom Broadcom wl.o driver - ipw Intel ipw2100/2200 driver - wired wpa_supplicant wired Ethernet driver - roboswitch wpa_supplicant Broadcom switch driver - bsd BSD 802.11 support (Atheros, etc.) - ndis Windows NDIS driver

EOF