Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to configure a wifi card using a command line or terminal
# source
How to configure a wifi card using a command line or terminal
This documentation is applicable on distributions such as Ubuntu, Debian, Trisquel, Linux Mint, and other similar distributions (anything derived from these in other words). The below works with at least versions of Ubuntu up to 14.10, Debian up to 8, and Trisquel up to 7. Most likely it'll work with future versions of these distributions as well. However if you believe the directions need updating please contact support.
You may also just want to check out these directions
Step 1: Give yourself administrative access:
sudo su
Step 2: Install wpasupplicant and wireless-tools:
Note: You will need a wired connection temporarily, or will need to copy the appropriate packages over from another computer. These packages may also already be installed. If they are then you can skip this step. If you have a ThinkPenguin USB Wireless N adapter you may also need to download firmware if on Debian, and place it in the /lib/firmware folder (htc_9271.fw firmware is for TPE-N150USB & TPE-N150USBL and htc_7010.fw firmware is for TPE-NUSBDB).
apt-get install wpasupplicant wireless-tools
Step 3: Identify your network adapter from a terminal by running the command below:
Note: Take note of the line with 802.11 on it and what comes to the left of it. This is you wireless card and you'll need in in the steps that follow.
The output of this command will look something like the following:
eth0 no wireless extensions.
wlan0 IEEE 802.11bgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Power Management:off
lo no wireless extensions.
Step 4: Stop Network Manager if it is running:
service network-manager stop
Step 5: Create a wpa_supplicant.conf file by replacing access_point_name with your SSID:
wpa_passphrase "access_point_name" > /etc/wpa_supplicant.conf
Note: You'll get a prompt to enter your access point password when you run the above command, enter it.
Step 6: Add the following at the end of your /etc/network/interfaces file and save (CTRL+X and hit Y):
nano /etc/network/interfaces
Add the follow to the bottom of the file (if your wireless adapter does not show up as wlan0 replace it with what did show up when running iwconfig above) to get an IP address automatically via your DHCP/router/access point:
auto wlan0
iface wlan0 inet dhcp
wpa-driver nl80211
wpa-conf /etc/wpa_supplicant.conf
If you prefer to set a static address:
auto wlan0
iface wlan0 inet static
wpa-driver nl80211
wpa-conf /etc/wpa_supplicant.conf
You will also need to add a nameserver to the /etc/resolv.conf file:
nano /etc/resolv.conf
nameserver (you can also replace this with your preferred nameserver; the one here is that of Google)
Notes for setting a static IP address: You'll need to determine the routers IP address in order to fill in the gateway address above. Most home routers have a default IP address of:,,,,, or is almost always the netmask. You probably won't need to change this.
The "address" line under iface is the address of the computer. Notice that you'll need to pick an IP address that is not in use by another computer on the network. The static address you pick also needs to be in the same address range as the router's IP address. If the router's address is then you would set a static IP like
Step 7: Activate the wireless connection:
ifup wlan0
Step 8: Test the connection
ping -c 5
After a few seconds you should see:
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
If it says 0% packet loss then you're successfully connected to the network (and internet).
Troubleshooting: if the wireless interface can connect to your LAN network but you cannot ping any host. Try this command and reboot
sudo apt-get purge bcmwl-kernel-source
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.