- How to List Compiled and Installed PHP Modules in Linux
- How to List Compiled PHP Modules
- How to List Installed PHP Modules
- How to Use the lsmod and modinfo Commands in Linux
- What are Linux Kernel Modules (LKM)?
- List Kernel Modules with lsmod
- Display Information About a Linux Kernel Module with modinfo
- Conclusion
- How to get a list of installed external kernel modules?
- 1 Answer 1
How to List Compiled and Installed PHP Modules in Linux
If you have installed a number of PHP extensions or modules on your Linux system and you trying to find out a particular PHP module has been installed or not, or you simply want to get a complete list of installed PHP extensions on your Linux system.
In this article, we will show you how to list all installed or compiled PHP modules from Linux command line.
How to List Compiled PHP Modules
The general command is php -m , which will show you a list of all “compiled” PHP modules.
apc bz2 calendar Core ctype curl date dom ereg exif fileinfo filter ftp gd gettext gmp hash iconv json libxml mbstring mcrypt mysql mysqli openssl pcntl pcre PDO pdo_mysql pdo_sqlite Phar readline Reflection session shmop SimpleXML sockets SPL sqlite3 standard tidy tokenizer wddx xml xmlreader xmlwriter xsl zip zlib
You can search for a specific PHP module for instance php-ftp , using the grep command. Simply pipe the output from the above command to grep as shown (grep -i flag means ignore case distinctions, thus typing FTP instead of ftp should work).
# php -m | grep -i ftp ftp
How to List Installed PHP Modules
To list all PHP modules that you have installed via a package manager, use the appropriate command below, for your distribution.
# yum list installed | grep -i php #RHEL/CentOS # dnf list installed | grep -i php #Fedora 22+ # dpkg --get-selections | grep -i php #Debian/Ubuntu
php.x86_64 5.3.3-49.el6 @base php-cli.x86_64 5.3.3-49.el6 @base php-common.x86_64 5.3.3-49.el6 @base php-devel.x86_64 5.3.3-49.el6 @base php-gd.x86_64 5.3.3-49.el6 @base php-mbstring.x86_64 5.3.3-49.el6 @base php-mcrypt.x86_64 5.3.3-5.el6 @epel php-mysql.x86_64 5.3.3-49.el6 @base php-pdo.x86_64 5.3.3-49.el6 @base php-pear.noarch 1:1.9.4-5.el6 @base php-pecl-memcache.x86_64 3.0.5-4.el6 @base php-php-gettext.noarch 1.0.12-1.el6 @epel php-tidy.x86_64 5.3.3-49.el6 @base php-xml.x86_64 5.3.3-49.el6 @base
In case you want to find one particular module, like before, use a pipe and the grep command as shown.
# yum list installed | grep -i php-mbstring #RHEL/CentOS # dnf list installed | grep -i php-mbstring #Fedora 22+ # dpkg --get-selections | grep -i php-mbstring #Debian/Ubuntu
To view all php command line options, run.
You might also like to check out these following useful articles about PHP.
That’s all! In this article, we’ve explained how to list installed (or compiled in) modules in PHP. Use the comment form below to ask any questions.
How to Use the lsmod and modinfo Commands in Linux
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
The Linux kernel is modular in nature, which means it’s possible to add and remove modules as needed. This makes for a lightweight, secure, and lightweight kernel. Its flexibility enables you to add and remove the features you need to make an operating system fit your use case and preferences.
It is important to inspect a Linux system’s kernel modules, especially when troubleshooting a hardware or software installation. For example, you may encounter an issue if a kernel module for a specific piece of hardware or software has not loaded. In this scenario, you use the lsmod command to view the available modules on your Linux system. If a module is loaded, you can further troubleshoot by listing out the details of the module. This is achieved using the modinfo command. This tutorial shows you how to use the lsmod and modinfo commands to inspect your Linux system’s kernel modules.
What are Linux Kernel Modules (LKM)?
Linux kernel modules are pieces of code that can be added to or removed from the Linux Kernel as required. Kernel modules often enable certain hardware or system features. Some modules are built directly into the kernel and cannot be removed. Loadable modules, on the other hand, can be added and removed without having to reboot your Linux system.
Loadable kernel modules allow you to extend the functionality of your system. Without modules, Linux would have to depend on a monolithic kernel which isn’t nearly as agile and secure. Another issue with a monolithic kernel is when new functionality is needed it must be built directly into the kernel image. This means the kernel is not only larger, but takes considerably longer to build. With monolithic kernels, every time new functionality is added, a system has to be rebooted.
Linux Kernel Modules are all stored in the /lib/modules directory. By keeping kernel modules housed in a centralized, local directory, it is more efficient to load and unload kernel modules. If you inspect the /lib/modules directory, you can find subdirectories for every kernel that has been installed on your system. For example, your Linux server might display the following installed kernels:
4.19.0-18-amd64 grub-2.04-19-linode.img
If you view the contents of one the kernel directory stored in the 4.19.0-18-amd64 directory, for example, you can view module files related to your system.
kernel modules.alias.bin modules.builtin.bin modules.dep.bin modules.order modules.symbols modules.alias modules.builtin modules.dep modules.devname modules.softdep modules.symbols.bin
List Kernel Modules with lsmod
The lsmod command stands for “list modules,” and lists out every loaded kernel module on a system. From a terminal, use the lsmod command to list all of your system’s kernel modules.
The output of the command can be very long and displays the output in three columns:
- Module — the name of the module.
- Size — the size of the module in bytes.
- Used by — how many instances of the module are in use and what system is using the module.
The example below displays what a system might return when you issue the lsmod command. The output displays every module that is loaded and the associated details.
Module Size Used by nfnetlink 16384 2 nf_conntrack_netlink xt_MASQUERADE 20480 1 nf_nat 49152 2 nft_chain_nat,xt_MASQUERADE nf_conntrack_netlink 49152 0 xfrm_user 40960 1 . .
The nfnetlink module displayed above is used as a transport layer for all user space communication of the netfilter subsystems. The module is 16,384 bytes in size and is used twice by the nf_conntrack_netlink system. This system enables support for a netlink-based user space interface. The lsmod command helps to identify this information about the nfnetlink module and can similarly provide information about all other modules installed on your Linux system.
Display Information About a Linux Kernel Module with modinfo
You can uncover even more information about a specific kernel module using the modinfo command. Continuing with the example above, you can view more information about the nfnetlink module, with the following command:
The output for the modinfo nfnetlink command displays the following information.
filename: /lib/modules/5.11.0-41-generic/kernel/net/netfilter/nfnetlink.ko description: Netfilter messages via netlink socket alias: net-pf-16-proto-12 author: Harald Welte license: GPL srcversion: EFA3D70B6EF087871934E84 depends: retpoline: Y intree: Y name: nfnetlink vermagic: 5.11.0-41-generic SMP mod_unload modversions sig_id: PKCS#7 signer: Build time autogenerated kernel key sig_key: 0A:76:69:99:20:71:05:D9:91:E8:8C:EC:C7:61:22:0B:A5:B5:70:EF sig_hashalgo: sha512 signature: 5F:F3:5C:6B:B4:7A.
- filename — the specific path housing the module (in this case, /lib/modules/5.11.0-41-generic/kernel/net/netfilter/nfnetlink.ko ).
- alias — the module alias used within the kernel.
- author — the author of the module.
- license — the module license.
- srcversion — the specific version of the module source.
- depends — any dependencies a module might have.
- retpoline — if the module is retpoline enabled.
- intree — if the module is maintained in the kernel Git repository
- name — the name of the module.
- vermagic — the version of the kernel module.
- sig_id, signer, sig_key, sig_hashalgo, and signature — all display information about the module’s key signature.
If the modinfo nfnetlink command displays too much information for your needs, you can specify which field you want to be displayed using the —field option. For example, if you only need to view the filename field, issue the following command:
modinfo --field filename nfnetlink
/lib/modules/5.11.0-41-generic/kernel/net/netfilter/nfnetlink.ko
By default, modinfo lists information for modules used by the current running kernel. You can also find information about a module for a specific kernel that may not be running on your system. Perhaps you want information about the nfnetlink module from the previous kernel. To do so, issue the following command:
modinfo -k 5.11.0-40-generic nfnetlink
The output for the above command only lists information for the module from the 5.11.0-40-generic kernel, instead of the currently running kernel.
Conclusion
Whenever you need information about a particular Linux kernel module, lsmod and modinfo are commands you can rely on. Using the combination of lsmod and modinfo , you can gather plenty of details for each available module. If you’re looking for more information on managing your Linux kernel, check out our Managing the Kernel on a Linode guide.
This page was originally published on Friday, January 7, 2022.
How to get a list of installed external kernel modules?
This implies that if I look into /lib/modules/$(KERNELRELEASE)/extra/ I can find all installed external kernel modules. However, I find that the official Nvidia display driver installs nvidia.ko into /lib/modules/$(KERNELRELEASE)/kernel/drivers/video/ . This contradicts the above rule and suggests that the path is not a reliable indicator of included/external modules. How to get a list of external kernel modules installed? If the distro matters, I’d like to know the answer for RHEL 6 and Ubuntu 10.04.
1 Answer 1
For Debian/Ubuntu, something like
dpkg -S *.ko | grep /lib/modules | grep -v linux-image
should work. Disclaimer: I’m illiterate when it comes to pattern matching, so there are probably better ways of doing this. On my system, I get
nvidia-kernel-2.6.32-5-vserver-686-bigmem: /lib/modules/2.6.32-5-vserver-686-bigmem/nvidia/nvidia.ko nvidia-kernel-2.6.26-2-vserver-686-bigmem: /lib/modules/2.6.26-2-vserver-686-bigmem/nvidia/nvidia.ko nvidia-kernel-2.6.26-1-vserver-686-bigmem: /lib/modules/2.6.26-1-vserver-686-bigmem/nvidia/nvidia.ko
This does assume that all installed modules are known to the packaging system, but this is generally a good idea anyway. At least on Debian, installing kernel modules as binary packages is generally possible. This approach has the advantage that it tells you which package a kernel module belongs to. Similar approaches should work with other Linux distributions which use a package management system; i.e. most of them.
Since the location of third party modules is similar to those of the in-kernel modules, it is not easy to distinguish them. Querying the package manager makes things easier. However, in my currently running kernel, in the directory /lib/modules/2.6.32-5-vserver-686-bigmem , I notice that the nvidia modules are in a separate directory from the main kernel modules, namely /lib/modules/2.6.32-5-vserver-686-bigmem/nvidia vs /lib/modules/2.6.32-5-vserver-686-bigmem/kernel . I don’t know if such a layout is Debian policy or not. The closest thing to Debian kernel policy I am aware of is The Debian Kernel Handbook, but I did not find anything relevant there. Of course, Ubuntu is not bound by Debian policy in any case.