Similar to a previous question about finding network device names, I would like to get a (reliable) list of device names but just for Wi-Fi devices. So that it looks like the following depending on your naming structure:




On linux you have iw (show/manipulate wireless devices and their configuration) and when used with the dev command:

        List all network interfaces for wireless hardware.

that is

iw dev

you'll get something like:

    Interface wlan0
        ifindex 3
        wdev 0x1
        addr 00:12:32:e4:18:24
        type managed
    Interface wlan1
        ifindex 4
        wdev 0x2
        addr 00:12:22:c6:b2:0a
        type managed

If you want to extract only interfaces names you can always process the output e.g.

iw dev | awk '$1=="Interface"{print $2}'

just keep in mind the help page clearly states:

Do NOT screenscrape this tool, we don't consider its output stable.
|improve this answer|||||
  • I like this answer, it solves the problem, but the bit about not scraping concerns me and makes me think there may be a better way. I'd like to leave this open for now. – Matt Copperwaite Jun 2 '16 at 16:51

On Ubuntu at least, there is the /proc/net/wireless file that contains details about the Wi-Fi interfaces. Which outputs for me:

$ cat /proc/net/wireless
Inter-| sta-|   Quality        |   Discarded packets               | Missed | WE
 face | tus | link level noise |  nwid  crypt   frag  retry   misc | beacon | 22
wlp5s0: 0000   36.  -74.  -256        0      0      0     16  33004        0

It's a little messy but the device name is in there.

To get just the interface name:

cat /proc/net/wireless | perl -ne '/(\w+):/ && print $1'

The perl code prints the string of word characters preceding the colon.

  • This did not work for me –probably because I have my wireless card disabled (but detectable). – imbuedHope Jan 17 '18 at 20:51

If you have sysfs mounted at /sys then the following commands work:

# find /sys/class/net -follow -maxdepth 2 -name wireless | cut -d / -f 5
# find /sys/class/net -follow -maxdepth 2 -name phy80211 | cut -d / -f 5

Or, without find:

for dev in `ls /sys/class/net`; do
  if [ -d "/sys/class/net/$dev/wireless" ]; then echo $dev; fi;

The first finds all devices in /sys/class/net with a wireless directory (which may be more than just WiFi devices) and the second finds devices that are 802.11 compatible

Tested on kernel 4.4

|improve this answer|||||

Building on Josh's answer, I'll use a shell glob to identify the /sys/class/net directories with a wireless directory inside, and awk to grab the device name:

# find the directories
$ printf '%s\n' /sys/class/net/*/wireless # substitute with phy80211 if desired
# filter out the "device" part
$ printf '%s\n' /sys/class/net/*/wireless | awk -F'/' '{ print $5 }'
|improve this answer|||||

Universal way (non root) tested on Android 4, Android 7.1 and Android 9 and ArchLinux.

ls /sys/class/ieee80211/*/device/net/
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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