Linux find installed modules

How can I find out where a Perl module is installed?

How do get the path of a installed Perl module by name, e.g. Time::HiRes ? I want this just because I have to run my perl script on different nodes of a SGE Grid Engine system. Sometimes, even run as other username. I can use CPAN.pm to install packages for myself, but it is not so easy to install for other users without chmod 666 on folders.

Why do you want to know this? Do you need it in another program or do you just want to see it on the command line?

10 Answers 10

perl -MTime::HiRes -e ‘print $INC’ or perldoc -l Time::HiRes

perldoc only works for those setupped. the first works for all, but typing the name 2 times is a bit boring.

That doesn’t tell you where Perl is looking for the file, though. My Perl modules are in ~/perl/install, for example.

Well, in my situation, user files all in NFS path, and locate just exclude NFS. Since the PERL5LIB is a bit long on that system, find is not a good way.

For Windows, might need to use double-quotes on the outside, single quotes on the inside. Command as given errors: Can’t find string terminator «‘» anywhere before EOF at -e line 1. on Windows 7. Command: perl -MTime::HiRes -e «print $INC<'Time/HiRes.pm'>» works.

Mostly I use perldoc to get a location:

You can also get module details with the cpan tool that comes with Perl:

$ cpan -D Time::HiRes Time::HiRes ------------------------------------------------------------------------- High resolution time, sleep, and alarm J/JH/JHI/Time-HiRes-1.9719.tar.gz /usr/local/perls/perl-5.10.0/lib/5.10.0/darwin-2level/Time/HiRes.pm Installed: 1.9711 CPAN: 1.9719 Not up to date Andrew Main (Zefram) (ZEFRAM) zefram@fysh.org 

It even works on modules that you haven’t installed:

$ cpan -D Win32::Process Win32::Process ------------------------------------------------------------------------- Interface to Win32 Process functions J/JD/JDB/Win32-Process-0.14.tar.gz Installed: CPAN: 0.14 Not up to date Jan Dubois (JDB) jand@activestate.com 

I think maybe I need an XML option like svn.

Читайте также:  Ftp protocol in linux

Note: This solution proposes use of a (self-authored) utility that you must download. While it offers what I believe to be helpful features, installing a third-party solution first is not an option for everyone.

I’ve created whichpm , a cross-platform CLI (Linux, macOS, Window) that locates installed Perl modules by module (package) name, and optionally reports information about them, including detection of accidental duplicates.

# Locate the Data::Dumper module. $ whichpm Data::Dumper /usr/lib/perl/5.18/Data/Dumper.pm # Locate the Data::Dumper module, and also print # version information and core-module status. $ whichpm -v Data::Dumper Data::Dumper 2.145 core>=5.005 /usr/lib/perl/5.18/Data/Dumper.pm # Locate the Data::Dumper module and open it in your system's default text # editor. $ whichpm -e Data::Dumper # Look for accidental duplicates of the Foo::Bar module. # Normally, only 1 path should be returned. $ whichpm -a Foo::Bar /usr/lib/perl/5.18/Foo/Bar.pm ./Foo/Bar.pm # Print the paths of all installed modules. $ whichpm -a 

Installation

Prerequisites: Linux, macOS, or Windows, with Perl v5.4.50 or higher installed.

Installation from the npm registry

With Node.js or io.js installed, install the package as follows:

[sudo] npm install whichpm -g 

Manual installation (macOS and Linux)

  • Download the CLI as whichpm .
  • Make it executable with chmod +x whichpm .
  • Move it or symlink it to a folder in your $PATH , such as /usr/local/bin (OSX) or /usr/bin (Linux).

Источник

how to find Linux module path

in the linux, lsmod lists a lot of modules. but how can we find where those module loaded from. for some modules,linux command «modprobe -l» shows a path but some are not.
edited i also tried «find» and «locate». both of them lists all kind of versions

locate fake /svf/SVDrv/kernel/linux/.fake.ko.cmd /svf/SVDrv/kernel/linux/.fake.mod.o.cmd /svf/SVDrv/kernel/linux/.fake.o.cmd /svf/SVDrv/kernel/linux/fake.ko /svf/SVDrv/kernel/linux/fake.mod.o /svf/SVDrv/kernel/linux/fake.o /svf/SVDrv.03.11.2014.16.00/kernel/linux/.fake.ko.cmd /svf/SVDrv.03.11.2014.16.00/kernel/linux/.fake.mod.o.cmd /svf/SVDrv.03.11.2014.16.00/kernel/linux/.fake.o.cmd /svf/SVDrv.03.11.2014.16.00/kernel/linux/fake.ko /svf/SVDrv.03.11.2014.16.00/kernel/linux/fake.mod.o /svf/SVDrv.03.11.2014.16.00/kernel/linux/fake.o /svf/SVDrv.04.29.2014.17.39/kernel/linux/.fake.ko.cmd /svf/SVDrv.04.29.2014.17.39/kernel/linux/.fake.mod.o.cmd /svf/SVDrv.04.29.2014.17.39/kernel/linux/.fake.o.cmd /svf/SVDrv.04.29.2014.17.39/kernel/linux/fake.ko /svf/SVDrv.04.29.2014.17.39/kernel/linux/fake.mod.o /svf/SVDrv.04.29.2014.17.39/kernel/linux/fake.o /svf/SVDrv.05.05.2014.11.25/kernel/linux/.fake.ko.cmd /svf/SVDrv.05.05.2014.11.25/kernel/linux/.fake.mod.o.cmd /svf/SVDrv.05.05.2014.11.25/kernel/linux/.fake.o.cmd /svf/SVDrv.05.05.2014.11.25/kernel/linux/fake.ko /svf/SVDrv.05.05.2014.11.25/kernel/linux/fake.mod.o /svf/SVDrv.05.05.2014.11.25/kernel/linux/fake.o /svf/SVDrv.05.05.2014.17.43/kernel/linux/.fake.ko.cmd /svf/SVDrv.05.05.2014.17.43/kernel/linux/.fake.mod.o.cmd /svf/SVDrv.05.05.2014.17.43/kernel/linux/.fake.o.cmd /svf/SVDrv.05.05.2014.17.43/kernel/linux/fake.ko /svf/SVDrv.05.05.2014.17.43/kernel/linux/fake.mod.o /svf/SVDrv.05.05.2014.17.43/kernel/linux/fake.o /svf/SVDrv.05.07.2014.14.59/kernel/linux/.fake.ko.cmd /svf/SVDrv.05.07.2014.14.59/kernel/linux/.fake.mod.o.cmd /svf/SVDrv.05.07.2014.14.59/kernel/linux/.fake.o.cmd /svf/SVDrv.05.07.2014.14.59/kernel/linux/fake.ko /svf/SVDrv.05.07.2014.14.59/kernel/linux/fake.mod.o /svf/SVDrv.05.07.2014.14.59/kernel/linux/fake.o 

Источник

How to list all loadable kernel modules?

I’m looking for a few kernel modules to load i2c-dev and i2c-bcm2708 . But the modprobe command returns:

sudo modprobe i2c-dev modprobe: module i2c-dev not found in modules.dep 

The kernel didnt compile this i2c-dev. You didnt find this module.The kernel modules located /lib/modules/’kernel-version’/drivers. When you are looking for linux drivers.

Читайте также:  Ati radeon linux driver install

You can check on /boot/config-‘kernel-version’ and read this config file.You should know which linux modules are loaded or modulars or during compiling kernel didnt enable i2c-dev module.

5 Answers 5

  • By default modprobe loads modules from kernel subdirectories located in the /lib/modules/$(uname -r) directory. Usually all files have extension .ko , so you can list them with
find /lib/modules/$(uname -r) -type f -name '*.ko' 
find /lib/modules/$(uname -r) -type f -name '*.ko*' 

Redhat 7 modules files are compressed in .xz (not sure if it is because of kernel version or OS version.. if someone can clarify it to me?) so I think you might not find them with jimmij’s find command. Use instead find /lib/modules/$(uname -r) -type f -name *.ko*

@posinux: beware : the shell may expand your *.ko* if you happen to have in your current dir some file matching it. better to escape it between single quotes: find /lib/modules/$(uname -r) -type f -name ‘*.ko*’

Type modprobe and press tab, the autocomplete list should contain all the loadable modules

Also its double tab, and you may get prompted that there is a specific large number of entries to list, then press y to list them. Also this answer does not provide the second part to OP’s question which directory are they located?

takes very long even on newer systems and doesn’t give a really good way to look at ll the entries. just paging into one direction of 30k possibilities is probably not very much enlightening

There is lsmod command of kmod package in Arch Linux what lists and shows the status of Linux kernel modules that contains other useful commands such as modinfo , rmmod modprobe too.

Читайте также:  Linux mint connection failed

To list all binaries provided by the package you can type:

pacman -Ql kmod | grep /bin/ --color=always 

, and you can also check for the owner package of a binary with pacman -Qo lsmod .

Q switch is to query locally installed packages (unlike S to synchronize, ie. to check remotely).

Where it’s important to highlight that lsmod only shows already loaded modules. The Author of this thread had the problem to load a module that wasn’t in the map of the loadable kernel modules. Besides, this solution only applies to archlinux. Which might be not the distribution of the Author and might not solve the problem for others.

@Akendo lsmod is also available on Ubuntu, at least. However, I agree this does not solve OP’s problem.

There is absolutely no point in talking about Arch specifically, and lsmod is a universally available command. Furthermore, the whole point of the question is to list loadable/available modules, whereas lsmod only prints listed modules. This answer should be moderated.

I prefer to use depmod . With the command: depmod -av|grep MOD_NAME , your system will generate the modules.dep/map files and grep through it. The -v parameter is important for verbosity and -a to ensure that all possible modules from /lib/modules/ are used for the modules.dep file.

This way it’s possible to ensure, that a requested kernel module is mapped to the kernel as loadable. When the desire kernel module is not listed in the output, you know that the kernel won’t find it.

According to man depmod option -a is not needed — it is enabled by default, if no file names are given in command line.

You can check how autocompletion does it:

$ complete -p modprobe complete -F _modprobe modprobe declare -f _modprobe _modprobe () < . 

In that function there's an internal _installed_modules

$ declare -f _installed_modules _installed_modules () < COMPREPLY=($(compgen -W "$(PATH="$PATH:/sbin" lsmod | awk '')" -- "$1")) > 

So lsmod | awk '' should show you the list of modules

Источник

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