Посмотреть 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.

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 .

@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 .

Источник

Как узнать сетевую карту в Linux

Иногда нужно посмотреть сетевые карты в Linux, подключенные к компьютеру, узнать имя продукта или технические характеристики карты, а также скорость передачи данных. Например, когда вы хотите проверить совместимость сетевого драйвера или модуля ядра с Ethernet адаптером необходимо знать его аппаратные спецификации, такие как: номер модели и производитель, (например: Broadcom NetXtreme, Intel I350), скорость (например: (1 Гбит/сек, 10 Гбит/сек), режим соединения (full/half duplex) и т д.

Читайте также:  Подключение wifi main aux

Также эта информация вам понадобится, если вы хотите подобрать драйвер для своего wifi адаптера. В этой инструкции я расскажу как узнать сетевую карту Linux и посмотреть все доступные ее характеристики.

Информация о сетевой карте с помощью Ethtool

Если вас интересует информация о проводной сетевой карте Ehternet, то вы можете воспользоваться утилитой Ethtool. Это инструмент командной строки для проверки и изменения настроек PCI Ethernet карт. Для установки Ethtool в Ubuntu или Debian используйте команду:

В других дистрибутивах установка производится аналогичным образом, только нужно использовать подходящий пакетный менеджер.

Для отображения настроек сетевой карты в ethtool запустите утилиту передав в параметрах имя сетевого адаптера. Права суперпользователя здесь нужны для того, чтобы утилита могла получить информацию о настройках локальной сети и статусе соединения.

net

Здесь вы можете посмотреть поддерживаемые режимы работы Supported link modes, скорость Speed и тип коннектора Port, а также состояние подключения. Для просмотра информации о сетевом драйвере и прошивке используйте опцию i:

net1

Здесь вы можете видеть какие режимы поддерживает прошивка, а также ее версию. Если вас интересует MAC адрес выполните:

net2

Информация о сетевой карте в lshw

Во втором способе мы воспользуемся утилитой для отображения подробной информации об аппаратуре Linux — lshw. С помощью нее вы можете посмотреть информацию не только о карте Ethernet, но и о Wifi адаптере, а также посмотреть список сетевых карт.

Для установки lshw на Ubuntu или Debian наберите:

Чтобы посмотреть узнать сетевую карту linux и просмотреть подробные сведения о ней, запустите утилиту со следующими параметрами:

net4

В выводе команды вы увидите все подключенные к системе сетевые интерфейсы, кроме того, тут показывается более подробная информация, чем в выводе предыдущей утилиты. В самом начале вы видите производителя — vendor и имя продукта — product, скорость передачи данных size, а также в разделе configuration можно найти поле driver, где указан используемый драйвер.

Список сетевых карт в lspci

Если вам нужно узнать только продукт и имя производителя вашей сетевой карты можно использовать lspci. Обычно lscpi уже предустановлена в системе, но если нет ее можно установить командой:

sudo apt install pciutils

Теперь для просмотра доступных сетевых карт используйте:

net5

Тут вы можете видеть, что к системе подключены две сетевые карты linux, для проводного интернета и беспроводная, обе от Broadcom.

Информация о сетевой карте с помощью ip

Утилита ip позволяет посмотреть более подробную информацию о сетевом протоколе для вашей карты. Для просмотра информации выполните:

net6

На снимке экрана вы видите две физические сетевые карты linux — wlan0 и eth0, а также два виртуальных устройства. Для каждой из карт можно узнать состояние и MAC адрес.

Выводы

В этой статье мы рассмотрели несколько способов узнать сетевую карту Linux. Вы можете посмотреть не только производителя и название устройства, но и его характеристики, такие как скорость сетевой карты linux, используемый драйвер и MAC адрес. Если у вас остались вопросы, спрашивайте в комментариях!

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Читайте также:  Royal clima установка wifi модуля

Источник

Find Out Network Adapters Available in Ubuntu Linux

Wondering which network adapters you are using in Ubuntu or any other Linux OS? It is very easy to to find out the manufacturer of the network adapters in your computer in Linux. Open a terminal and use the following command:

If the above command doesn’t work with sudo, remove the super user privileges. Weird but helps. The output of the command reads like this:

Find out network adapter in Linux

*-network
description: Wireless interface
product: BCM4360 802.11ac Wireless Network Adapter
vendor: Broadcom Corporation
physical id: 0
bus info: [email protected]:03:00.0
logical name: wlan0
version: 03
serial: 9c:f3:87:c1:5d:6a
width: 64 bits
clock: 33MHz
capabilities: bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=wl0 driverversion=6.30.223.248 (r487574) ip=192.168.1.23 latency=0 multicast=yes wireless=IEEE 802.11abg
resources: irq:18 memory:b0600000-b0607fff memory:b0400000-b05fffff

As you can see, the wireless network adapter in my Macbook Air is BCM4360, a troublesome wireless adapter because of which often Ubuntu does not detect wireless networks.

lshw command actually used to list hardware in Linux and hence the command is named lshw. With the option network, it filters the result for networking hardware only.

Alternate method to know the network adapter

Alternatively, you can use lspci command that displays the information about PCI buses in the system. You should not need super user privileges to use this command. Just type the command in terminal:

The output of the command reads as:

Find out Network Adapter in Ubuntu command line

00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Controller (rev 09)
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 09)
00:03.0 Audio device: Intel Corporation Haswell-ULT HD Audio Controller (rev 09)
00:14.0 USB controller: Intel Corporation 8 Series USB xHCI HC (rev 04)
00:16.0 Communication controller: Intel Corporation 8 Series HECI #0 (rev 04)
00:1b.0 Audio device: Intel Corporation 8 Series HD Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 1 (rev e4)
00:1c.1 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 2 (rev e4)
00:1c.2 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 3 (rev e4)
00:1c.4 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 5 (rev e4)
00:1c.5 PCI bridge: Intel Corporation 8 Series PCI Express Root Port 6 (rev e4)
00:1f.0 ISA bridge: Intel Corporation 8 Series LPC Controller (rev 04)
00:1f.3 SMBus: Intel Corporation 8 Series SMBus Controller (rev 04)
02:00.0 Multimedia controller: Broadcom Corporation Device 1570
03:00.0 Network controller: Broadcom Corporation BCM4360 802.11ac Wireless Network Adapter (rev 03)
04:00.0 SATA controller: Marvell Technology Group Ltd. 88SS9183 PCIe SSD Controller (rev 14)

These command gives you information about both wired and wireless network adapters. You might have noticed that there is no wired network adapter for my system in the output above. The reason is that I am using a Macbook Air and it does not have an Ethernet port.

I hope this quick post helped you to find the network adapters in your Linux system. Any questions or suggestions are always welcomed.

Источник

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