Linux lsmod 命令

Linux命令是对Linux系统进行管理的命令。对于Linux系统来说,无论是中央处理器、内存、磁盘驱动器、键盘、鼠标,还是用户等都是文件,Linux系统管理的命令是它正常运行的核心,与之前的DOS命令类似。linux命令在系统中有两种类型:内置Shell命令和Linux命令。本文主要介绍Linux lsmod 命令。

 1、命令简介

lsmod:用于显示已加载的内核模块列表的 Linux 命令。内核模块是一种可以在运行时加载和卸载的代码,用于扩展操作系统内核的功能。

2、命令语法

lsmod [options] 

3、命令描述

lsmod显示所有加载模块的信息。格式为名称、大小、使用计数、引用模块列表。显示的信息与/proc/modules中提供的信息相同如果模块通过can_unload例程控制自己的卸载,那么lsmod显示的用户计数总是-1,而不管实际的使用计数是多少。模块文件的扩展名是.ko。

4、使用示例

1)列出当前加载的模块

[root@kvm1 ~]# lsmod
Module                  Size  Used by
iptable_nat            12875  1 
nf_nat_ipv4            14115  1 iptable_nat
nf_nat                 26787  1 nf_nat_ipv4
iptable_mangle         12695  1 
iptable_security       12705  1 
iptable_raw            12678  1 
ipt_REJECT             12541  2 
nf_reject_ipv4         13373  1 ipt_REJECT
nf_conntrack_ipv4      15053  2 
nf_defrag_ipv4         12729  1 nf_conntrack_ipv4
xt_conntrack           12760  1 
nf_conntrack          133053  4 nf_nat,nf_nat_ipv4,xt_conntrack,nf_conntrack_ipv4
iptable_filter         12810  1 
iosf_mbi               14990  0 
crc32_pclmul           13133  0 
ghash_clmulni_intel    13273  0 
ppdev                  17671  0 
aesni_intel           189414  0 
lrw                    13286  1 aesni_intel
gf128mul               15139  1 lrw
glue_helper            13990  1 aesni_intel
ablk_helper            13597  1 aesni_intel
pcspkr                 12718  0 
sg                     40721  0 
cryptd                 20511  3 ghash_clmulni_intel,aesni_intel,ablk_helper
joydev                 17389  0 
i2c_piix4              22401  0 
parport_pc             28205  0 
virtio_balloon         18015  0 
parport                46395  2 ppdev,parport_pc
ip_tables              27126  5 iptable_security,iptable_filter,iptable_mangle,iptable_nat,iptable_raw
xfs                  1003971  2 
libcrc32c              12644  3 xfs,nf_nat,nf_conntrack
sr_mod                 22416  0 
cdrom                  42556  1 sr_mod
ata_generic            12923  0 
pata_acpi              13053  0 
cirrus                 24383  1 
drm_kms_helper        176920  1 cirrus
syscopyarea            12529  1 drm_kms_helper
sysfillrect            12701  1 drm_kms_helper
sysimgblt              12640  1 drm_kms_helper
fb_sys_fops            12703  1 drm_kms_helper
ttm                    99555  1 cirrus
drm                   397988  4 ttm,drm_kms_helper,cirrus
ata_piix               35052  0 
virtio_console         28075  1 
virtio_blk             18166  3 
libata                242992  3 pata_acpi,ata_generic,ata_piix
crct10dif_pclmul       14307  0 
crct10dif_common       12595  1 crct10dif_pclmul
virtio_net             28063  0 
crc32c_intel           22094  1 
serio_raw              13434  0 
floppy                 69432  0 
i2c_core               63151  3 drm,i2c_piix4,drm_kms_helper
virtio_pci             22934  0 
virtio_ring            22746  5 virtio_blk,virtio_net,virtio_pci,virtio_balloon,virtio_console
virtio                 14959  5 virtio_blk,virtio_net,virtio_pci,virtio_balloon,virtio_console
dm_mirror              22289  0 
dm_region_hash         20813  1 dm_mirror
dm_log                 18411  2 dm_region_hash,dm_mirror
dm_mod                123941  8 dm_log,dm_mirror

2)同样加载的模块也可以在/proc/modules中看到

[root@kvm1 ~]# cat /proc/modules
iptable_nat 12875 1 - Live 0xffffffffc06d5000
nf_nat_ipv4 14115 1 iptable_nat, Live 0xffffffffc06da000
nf_nat 26787 1 nf_nat_ipv4, Live 0xffffffffc06cd000
iptable_mangle 12695 1 - Live 0xffffffffc06c8000
iptable_security 12705 1 - Live 0xffffffffc06c3000
iptable_raw 12678 1 - Live 0xffffffffc06be000
ipt_REJECT 12541 2 - Live 0xffffffffc06b9000
nf_reject_ipv4 13373 1 ipt_REJECT, Live 0xffffffffc06b4000
nf_conntrack_ipv4 15053 2 - Live 0xffffffffc06ab000
nf_defrag_ipv4 12729 1 nf_conntrack_ipv4, Live 0xffffffffc067f000
xt_conntrack 12760 1 - Live 0xffffffffc067a000
nf_conntrack 133053 4 nf_nat_ipv4,nf_nat,nf_conntrack_ipv4,xt_conntrack, Live 0xffffffffc0689000
iptable_filter 12810 1 - Live 0xffffffffc0684000
iosf_mbi 14990 0 - Live 0xffffffffc066a000
crc32_pclmul 13133 0 - Live 0xffffffffc0665000
ghash_clmulni_intel 13273 0 - Live 0xffffffffc0675000
ppdev 17671 0 - Live 0xffffffffc066f000
aesni_intel 189414 0 - Live 0xffffffffc0635000
lrw 13286 1 aesni_intel, Live 0xffffffffc0630000
gf128mul 15139 1 lrw, Live 0xffffffffc062b000
glue_helper 13990 1 aesni_intel, Live 0xffffffffc0626000
ablk_helper 13597 1 aesni_intel, Live 0xffffffffc060c000
pcspkr 12718 0 - Live 0xffffffffc0611000
sg 40721 0 - Live 0xffffffffc0601000
cryptd 20511 3 ghash_clmulni_intel,aesni_intel,ablk_helper, Live 0xffffffffc061f000
joydev 17389 0 - Live 0xffffffffc05fb000
i2c_piix4 22401 0 - Live 0xffffffffc05e9000
parport_pc 28205 0 - Live 0xffffffffc05f3000
virtio_balloon 18015 0 - Live 0xffffffffc05d6000
parport 46395 2 ppdev,parport_pc, Live 0xffffffffc05dc000
ip_tables 27126 5 iptable_nat,iptable_mangle,iptable_security,iptable_raw,iptable_filter, Live 0xffffffffc0617000
xfs 1003971 2 - Live 0xffffffffc04df000
libcrc32c 12644 3 nf_nat,nf_conntrack,xfs, Live 0xffffffffc0482000
sr_mod 22416 0 - Live 0xffffffffc0487000
cdrom 42556 1 sr_mod, Live 0xffffffffc0476000
ata_generic 12923 0 - Live 0xffffffffc03f6000
pata_acpi 13053 0 - Live 0xffffffffc0400000
cirrus 24383 1 - Live 0xffffffffc04d8000
drm_kms_helper 176920 1 cirrus, Live 0xffffffffc04ab000
syscopyarea 12529 1 drm_kms_helper, Live 0xffffffffc0471000
sysfillrect 12701 1 drm_kms_helper, Live 0xffffffffc046c000
sysimgblt 12640 1 drm_kms_helper, Live 0xffffffffc03fb000
fb_sys_fops 12703 1 drm_kms_helper, Live 0xffffffffc0371000
ttm 99555 1 cirrus, Live 0xffffffffc0491000
drm 397988 4 cirrus,drm_kms_helper,ttm, Live 0xffffffffc0409000
ata_piix 35052 0 - Live 0xffffffffc03ec000
virtio_console 28075 1 - Live 0xffffffffc038c000
virtio_blk 18166 3 - Live 0xffffffffc0382000
libata 242992 3 ata_generic,pata_acpi,ata_piix, Live 0xffffffffc03af000
crct10dif_pclmul 14307 0 - Live 0xffffffffc037d000
crct10dif_common 12595 1 crct10dif_pclmul, Live 0xffffffffc0376000
virtio_net 28063 0 - Live 0xffffffffc0353000
crc32c_intel 22094 1 - Live 0xffffffffc03a8000
serio_raw 13434 0 - Live 0xffffffffc036c000
floppy 69432 0 - Live 0xffffffffc0396000
i2c_core 63151 3 i2c_piix4,drm_kms_helper,drm, Live 0xffffffffc035b000
virtio_pci 22934 0 - Live 0xffffffffc0345000
virtio_ring 22746 5 virtio_balloon,virtio_console,virtio_blk,virtio_net,virtio_pci, Live 0xffffffffc034c000
virtio 14959 5 virtio_balloon,virtio_console,virtio_blk,virtio_net,virtio_pci, Live 0xffffffffc0331000
dm_mirror 22289 0 - Live 0xffffffffc033e000
dm_region_hash 20813 1 dm_mirror, Live 0xffffffffc032a000
dm_log 18411 2 dm_mirror,dm_region_hash, Live 0xffffffffc0338000
dm_mod 123941 8 dm_mirror,dm_log, Live 0xffffffffc030a000

推荐阅读
cjavapy编程之路首页