
linux命令lspci
Linux provides lspci
command in order to list PCI bus and devices information. This command will provide brief or detailed information about currently connected PCI devices like GPU, USB Card etc.
Linux提供lspci
命令以列出PCI总线和设备信息。 该命令将提供有关当前连接的PCI设备(如GPU,USB卡等)的简要或详细信息。
为Ubuntu,Debian,Kali,Mint安装 (Install For Ubuntu, Debian, Kali, Mint)
We can install lspci
tool with the following command to the deb
based distributions.
我们可以使用以下命令将lspci
工具安装到基于deb
的发行版中。
$ sudo apt install pciutils

为Fedora,CentOS,Fedora安装(Install For Fedora, CentOS, Fedora)
In yum
or dnf
based distributions we can use the following command which will install the package named pciutils
.
在基于yum
或dnf
的发行版中,我们可以使用以下命令来安装名为pciutils
的软件包。
$ sudo yum install pciutils

列出PCI设备(List PCI Devices)
We will start with the simplest form where we will do not provide any option to this command. This will print PCI Address or slot information with the device type and vendor information.
我们将从最简单的形式开始,在该形式中,我们将不为该命令提供任何选项。 这将打印PCI地址或插槽信息以及设备类型和供应商信息。
$ lspci

显示指定的插槽或地址设备(Show Specified Slot or Address Devices)
Most of the computers have a few PCI interfaces. This may list a lot of information which will jam the output. Or we may be interested in the specific PCI slot of address. In this example, we will print information about PCI slot number 00:10.0
which is SCSI device controller.
大多数计算机都有一些PCI接口。 这可能会列出很多会阻塞输出的信息。 或者我们可能对地址的特定PCI插槽感兴趣。 在此示例中,我们将打印有关PCI插槽号00:10.0
即SCSI设备控制器)的信息。
$ lspci -s 00:10.0

打印机器可读格式(Print Machine-Readable Format)
The default printing format is human-readable format. This means PCI address or slot, vendor and product information is printed in a space delimited format. Machine-readable format is a double quote separated format which can be parsed easily.
默认的打印格式是人类可读的格式。 这意味着PCI地址或插槽,供应商和产品信息以空格分隔的格式打印。 机器可读格式是一种双引号分隔的格式,可以轻松解析。
$ lspci -m

详细输出(Verbose Output)
PCI bus provides a lot of information about the PCI connection and the devices. By default, this information is not printed completely. We can print detailed information about this PCI connection and device with the verbose -v
option like below.
PCI总线提供了大量有关PCI连接和设备的信息。 默认情况下,此信息未完全打印。 我们可以使用下面的详细-v
选项打印有关此PCI连接和设备的详细信息。
$ lspci -v

We can see that for every PCI device information like Subsystem, Flag, Memory Location or Address, Kernel Driver In Use, Kernel Modules, I/O ports etc.
我们可以看到每个PCI设备的信息,例如子系统,标志,内存位置或地址,正在使用的内核驱动程序,内核模块,I / O端口等。
以标签:值格式打印信息 (Print Information In Tag:Value Format)
We can also print PCI Slot and Devices information in tag:value format. This will make the information readable like JSON format. We will use -vmms
option like below.
我们还可以使用tag:value格式打印PCI插槽和设备信息。 这将使信息像JSON格式一样可读。 我们将使用-vmms
选项,如下所示。
$ lspci -vmm

打印设备供应商代码(Print Device Vendor Codes)
Every computer hardware manufacturer has its own vendor and device code or ID. We can print device vendor, class, svendor,sdevice ID with the -n
option like below.
每个计算机硬件制造商都有自己的供应商和设备代码或ID。 我们可以使用-n
选项打印设备供应商,类,供应商,sdevice ID,如下所示。
$ lspci -n -vmm

显示PCI设备的内核模块(Show Kernel Module Of The PCI Devices)
As very PCI device have its kernel module and driver to be used by the Linux operating system. We can list all kernel and drivers with the -k
option like below.
由于PCI设备具有其内核模块和驱动程序供Linux操作系统使用。 我们可以使用-k
选项列出所有内核和驱动程序,如下所示。
$ lspci -k

We can see that the following information is provided by -k
.
我们可以看到-k
提供了以下信息。
- Device Name 设备名称
- Subsystem子系统
- Kernel driver内核驱动
- Kernel module内核模块
以树格式列出PCI设备 (List PCI Devices In Tree Format)
Up to now, we have listed PCI Devices in a line by line or regular format. We can also list the output of the lspci
in a tree format with a hierarchical manner. We will use -t
option like below.
到目前为止,我们已经按行或常规格式列出了PCI设备。 我们还可以通过树的方式以分层方式列出lspci
的输出。 我们将使用-t
选项,如下所示。
$ lspci -tv

We can see that some devices are listed under VMware USB controller.
我们可以看到某些设备在VMware USB控制器下列出。
非常详细模式所有详细信息 (Very Verbose Mode All Details)
We have already printed detailed or verbose information about the PCI slots. We will use multiple -v
option -vv
or -vvv
. More v
means more verbose or detail.
我们已经打印了有关PCI插槽的详细信息。 我们将使用多个-v
选项-vv
或-vvv
。 v
越大,意味着越详细或细节。
$ lspci -vv
翻译自: https://www.poftut.com/linux-lspci-command-tutorial-with-examples/
linux命令lspci