I installed Ubuntu Server on an older machine at the office recently. We only have WiFi access, no Ethernet, and the machine does not have a wireless chip. I got a D-Link WiFi USB adapter and plugged it in. Fine, but now, how do I tell Ubuntu to use the newly installed wireless adapter when you only have a CLI and no GUI?
Easy… well, not exactly, but it works.
Detecting the USB adapter
Let's first check if the machine detected the USB adapter. Run lsusb to list the USB devices the machine knows about:
There it is, our D-Link Corp. wireless USB adapter. Nice.
Naming the adapter
Now we need to find the USB device's logical name, the name we can use to refer to it. Meet lshw.
Look for a device with a logical name starting with a 'w' (for wireless) and take note of it's name.
We now we have a USB device and we know how to address it. Let's try to manually connect to a wireless network, make sure it's running first:
wlan0 as a generic device name here but you'll need to replace it with the logical name you found in the previous step.
Now connect to your wireless network:
It looks like the program hangs but it's simply waiting for you to give it the password to access the wireless network. Enter the password and press enter, it will create a
wlan.conf file in the same directory containing the password and network name.
Connect to the network:
There won't be a lot to do without IP address so let's ask our router to give us one:
You should now be connected with the router. Check if you can see the internet:
Persist the config
This is all fine… until you reboot and need to do the whole thing over again. Not optimal. It would be wise to store this somewhere so Ubuntu can reconnect to this network after a reboot. Let's use what we learned above and save that in a file. Open the
/etc/network/interfaces file and add the following:
You'll need to replace the
wlan0 with the logical name you found earlier and 192.168.0.1 with the address of your router of course. Once done take down the interface and bring it back up:
Still connected? Great, the internet awaits you.