当前位置: 首页 > 工具软件 > JTaro Module > 使用案例 >

module

万俟嘉珍
2023-12-01

module概述

module 是 *nix 系统上加载/管理模块的命令。

module安装

大多数发行版上并未默认安装,运行该命令则会出现如下错误:

module: command not found。

需手动执行安装命令,安装软件包 environment-modules:

  1. For CentOS:
    [root@localhost ~]# dnf install environment-modules
  2. For Ubuntu:
    [miya@localhost ~]# sudo apt-get install environment-modules

注意:安装完成后,已打开的终端要重新打开,命令才能生效。

语法格式

module [options] [command] [args ...]

参考实例

  1. 列出已加载的模块:list
    [root@localhost ~]# module list
    No Modulefiles Currently Loaded.
  2. 查看可用模块:avail
    [root@localhost ~]# module avail
    -------------------------------------------------- /usr/share/Modules/modulefiles ---------------------------------------------------
    dot  module-git  module-info  modules  null  use.own
  3. 显示模块信息:show/display
    [root@localhost ~]# module avail
    -------------------------------------------------- /usr/share/Modules/modulefiles ---------------------------------------------------
    dot  module-git  module-info  modules  null  use.own
    
    ------------------------------------------------------- /root/privatemodules --------------------------------------------------------
    null
    [root@localhost ~]# 
    [root@localhost ~]# module show null
    -------------------------------------------------------------------
    /usr/share/Modules/modulefiles/null:
    
    module-whatis   {does absolutely nothing}
    -------------------------------------------------------------------
    [root@localhost ~]# 
    [root@localhost ~]# module display module-git
    -------------------------------------------------------------------
    /usr/share/Modules/modulefiles/module-git:
    
    module-whatis   {get last version of the module sources from GitHub}
    set-alias       get-modules {git clone git://github.com/cea-hpc/modules.git && cd modules}
    -------------------------------------------------------------------
  4. 加载模块:add/load
    [root@localhost ~]# module add dot
    [root@localhost ~]# module load use.own
    [root@localhost ~]# module list
    Currently Loaded Modulefiles:
     1) dot   2) use.own
  5. 重新加载模块:reload/refresh
    [root@localhost ~]# module reload
    [root@localhost ~]# module refresh
  6. 卸载模块:rm/unload
    [root@localhost ~]# module list
    Currently Loaded Modulefiles:
     1) use.own   2) dot
    [root@localhost ~]# module rm use.own
    [root@localhost ~]# module unload dot
    [root@localhost ~]# module list
    No Modulefiles Currently Loaded.
  7. 清空模块:clear/purge
    [root@localhost ~]# module list
    Currently Loaded Modulefiles:
     1) null
    [root@localhost ~]# module clear
    Are you sure you want to clear all loaded modules!? [n] y
    [root@localhost ~]# module list
    No Modulefiles Currently Loaded.
    [root@localhost ~]# 
    [root@localhost ~]# module list
    No Modulefiles Currently Loaded.
    [root@localhost ~]# module add null
    [root@localhost ~]# module list
    Currently Loaded Modulefiles:
     1) null
    [root@localhost ~]# module purge
    [root@localhost ~]# module list
    No Modulefiles Currently Loaded.

 类似资料: