Узнать wifi модуль linux

Get Wi-Fi interface device names

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:

9 Answers 9

With nmcli you could list all devices and their type e.g.

nmcli --get-values GENERAL.DEVICE,GENERAL.TYPE device show
eno1 ethernet wlp1s0 wifi wlp1s1 wifi p2p-dev-wlp1s0 wifi-p2p lo loopback 

Per the manual, when using -g, —get-values , the «output is terse. This mode is designed and suitable for computer (script) processing». So you can pipe that output to other tools and get the wifi devices names e.g.

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

Commands: dev List all network interfaces for wireless hardware. 
phy#0 Interface wlan0 ifindex 3 wdev 0x1 addr 00:12:32:e4:18:24 type managed phy#1 Interface wlan1 ifindex 4 wdev 0x2 addr 00:12:22:c6:b2:0a type managed 

To extract only interfaces names you could process the output e.g.

just keep in mind the help page clearly states:

Do NOT screenscrape this tool, we don't consider its output stable. 

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.

The ‘Do NOT screenscrape’ comment only seems to appear when help is shown, due to invalid input or an explicit help command, but not in the output of valid results.

Just a reminder that you may need to run this as root i.e. sudo iw dev , because running it as a non-privileged user may return no results.

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.

Читайте также:  Обновить время через интернет linux

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.

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

ls /sys/class/ieee80211/*/device/net/ 

Great answer. To dump only relevant info, ls /sys/class/ieee80211/*/device/net/* -d | sed -E ‘s|^.*(phy[^/]+)/.*/|\1 |’

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 wlan0 $ find /sys/class/net -follow -maxdepth 2 -name phy80211 | cut -d / -f 5 wlan0 
for dev in `ls /sys/class/net`; do [ -d "/sys/class/net/$dev/wireless" ] && echo "$dev" done 

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

Even though sysfs probably has sane file names, parsing the output of ls is bad practice and a common pit fall in bash.

I like the find solution too; it only finds files that actually exist which solves the awkward * that other solutions here get. I found that I needed a slightly different set of parameters to reduce the amount of noise cause by file system loops. The following works nicely for me, but does spawn an extra subshell for cut and relies on assumptions about indexes: find -H /sys/class/net/* -name wireless | cut -d / -f 5 Furthermore I needed an additional | head -n1 for my particular use-case.

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

# find the directories $ printf '%s\n' /sys/class/net/*/wireless # substitute with phy80211 if desired /sys/class/net/wlp4s0/wireless # filter out the "device" part $ printf '%s\n' /sys/class/net/*/wireless | cut -d/ -f5 wlp4s0 

Note that this will still print * if no wireless device exists, instead of an empty result. Instead, try this with only POSIX shell built-ins: printf ‘%s\n’ /sys/class/net/*/wireless | while IFS=’/’ read -r -a p;do [ -e «/sys/class/net/$» ] && echo «$»;done .

Читайте также:  Linux install redis cli

@Yeti posix-sh doesn’t have arrays though? As for printing the glob versus an empty result, I think (at least for some shells) that depends on nullglob.

Why not just filter the unwanted * out: printf ‘%s\n’ /sys/class/net/*/wirelessREMOVETHIS | cut -d / -f 5 | grep -v ‘*’

@StephanHenningsen good use of cut instead of awk, edited. I’m not convinced on the * part though; I really think it depends on what you’re doing, what the shell options are, and whether or not your device might have an asterisk in it (shudders)

Here’s a simple and very effective loop that answers the question:

for dev in /sys/class/net/*; do [ -e "$dev"/wireless ] && echo $ done 

This one picks the first wireless interface and stores it in $iwdev , which was what I needed:

for dev in /sys/class/net/*; do if [ -e "$dev"/wireless ]; then iwdev=$; break; fi done 

It’s a rewrite of Josh’s answer which I found nice and simple. The above approach handles spaces and other oddities in file names. It also doesn’t make too many assumptions about file paths being sane and relies on a minimum of slashes and indexing. Finally it uses built-in parameter expansion for extracting the base device name instead of spawning a subshell for cut or awk .

Источник

How can I check the information of currently installed WiFi drivers?

When I clicked on additional drivers on Ubuntu 12.04, I could not see any drivers.. How can I check what drivers are installed for WiFi on Ubuntu environment.

It’s not really possible (or useful) to enumerate all available device drivers in Linux (even when restricted to a particular device class). However, you can enumerate all available drivers that are capable of handling a particular device and, more importantly, the one currently claiming the device, i. e. the driver used to “drive” it.

6 Answers 6

The following commands are run in a terminal. Open one by Ctrl + Alt + T .

To check what drivers your wireless adapter is currently using, you may run the following command:

  • lshw lists information on your hardware
  • -C network filters the output to only show the network class.
Читайте также:  Linux mint rpm to deb

In the output, look for the entry with description: Wireless interface .

Here’s the output from my Ubuntu:

alaa@aa-lu:~$ sudo lshw -C network [sudo] password for alaa: *-network description: Wireless interface product: RTL8723AE PCIe Wireless Network Adapter vendor: Realtek Semiconductor Co., Ltd. physical id: 0 bus info: pci@0000:08:00.0 logical name: wlan0 version: 00 serial: 24:ec:99:21:c9:29 width: 64 bits clock: 33MHz capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless configuration: broadcast=yes driver=rtl8723ae driverversion=3.8.0-27-generic firmware=N/A ip=192.168.1.74 latency=0 link=yes multicast=yes wireless=IEEE 802.11bgn resources: irq:17 ioport:3000(size=256) memory:c3000000-c3003fff

In the configuration line (line before last), you’ll see the driver currently being used by my card. I’ve highlighted it in the output.

Alternatively, you can use the command:

  • lspci lists information on your PCI connected cards
  • -nnk instructs lspci to output more information about these cards (including the driver being used)
  • | pipes the output to the next command
  • grep 0280 filters the output to show lines containing 0280 , which is the PCI class code for wireless PCI controllers in Ubuntu.
  • -A2 shows two more lines of information.

Here’s the output from my Ubuntu:

08:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. RTL8723AE PCIe Wireless Network Adapter [10ec:8723] Subsystem: Realtek Semiconductor Co., Ltd. Device [10ec:0724] Kernel driver in use: rtl8723ae 

Once you determine the driver you’re using, you can use the following command to show more information about it:

To check what wireless drivers you currently have installed, but not necessarily being used by anything, you can do the following command:

find /lib/modules/$(uname -r)/kernel/drivers/net/wireless -name '*.ko' 

The above command will list all drivers you have installed. This will probably be an exhaustive list, because these are preinstalled drivers on your Ubuntu to make it possible for people to use their wireless drivers as soon as they install Ubuntu.

Источник

Оцените статью
Adblock
detector