zoukankan      html  css  js  c++  java
  • 软件包查询-rpm查询常用命令

    软件包查询


    〇、测试环境
    [root@osker ~]# cat /etc/redhat-release
    CentOS Linux release 7.7.1908 (Core)
    [root@osker ~]# uname -r
    5.4.2-1.el7.elrepo.x86_64

    [root@osker ~]# rpm --version
    RPM version 4.11.3


    一、包查询
    有时候知道命令需要查找命令对应的安装包名(有时候命令名称和包名不是同一个名字)
    方法1、
    先使用whereis命令,查询出命令的路径
    [root@osker ~]# whereis ls
    ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
    再使用rpm -qf查询系统文件属于哪个软件包(file)
    [root@osker ~]# rpm -qf  /usr/bin/ls
    coreutils-8.22-24.el7.x86_64
    方法2、
    [root@osker ~]# yum provides ls
    Loaded plugins: fastestmirror
    ...
     * updates: mirror.newmediaexpress.com
    coreutils-8.22-24.el7.x86_64 : A set of basic GNU tools commonly used in shell scripts
    Repo        : base
    Matched from:
    Filename    : /usr/bin/ls


    二、rpm -q 常用查询命令
    rpm:RPM Package Manager
    rpm {-q|--query} [select-options] [query-options]

    1、-q:查询(query)
    查询软件包是否安装,命令格式如下:
    rpm -q 软件包名
    例:
    [root@osker ~]# rpm -q net-tools
    net-tools-2.0-0.25.20131004git.el7.x86_64
    [root@osker ~]# rpm -q ifconfig
    package ifconfig is not installed
    注意是接包名不是命令名

    2、-qa:查询所有安装的包(all)
    -a, --all:Query all installed packages.
    rpm -qa
    例:
    [root@osker ~]# rpm -qa
    libXdamage-1.1.4-4.1.el7.x86_64
    dbus-python-1.1.1-9.el7.x86_64
    setup-2.8.71-10.el7.noarch
    libXpm-3.5.12-1.el7.x86_64
    ...
    [root@osker ~]# rpm -qa |grep net-tools
    net-tools-2.0-0.25.20131004git.el7.x86_64

    3、-qi查询软件包的详细信息(information)
    -i, --info:Display package information, including name, version, and description.
    rpm -qi 包名
    例:
    [root@osker ~]# rpm -qi net-tools
    Name        : net-tools
    #包名
    Version     : 2.0
    #版本
    Release     : 0.25.20131004git.el7
    Architecture: x86_64
    #架构
    Install Date: Fri 22 Nov 2019 04:28:51 AM CST
    #安装时间
    Group       : System Environment/Base
    Size        : 938978
    License     : GPLv2+
    Signature   : RSA/SHA256, Fri 23 Aug 2019 05:36:04 AM CST, Key ID 24c6a8a7f4a80eb5
    #签名
    Source RPM  : net-tools-2.0-0.25.20131004git.el7.src.rpm
    #源RPM包名
    Build Date  : Fri 09 Aug 2019 09:10:26 AM CST
    Build Host  : x86-02.bsys.centos.org
    Relocations : (not relocatable)
    Packager    : CentOS BuildSystem <http://bugs.centos.org>
    Vendor      : CentOS
    URL         : http://sourceforge.net/projects/net-tools/
    Summary     : Basic networking tools
    Description :
    The net-tools package contains basic networking tools,
    including ifconfig, netstat, route, and others.
    Most of them are obsolete. For replacement check iproute package.

    4、-ql(list)查询已经安装的软件包中的文件列表和安装的完整目录
    rpm -ql 包名
    -l, --list:List files in package.
    例:
    [root@osker ~]# rpm -ql vim-enhanced
    /etc/profile.d/vim.csh
    /etc/profile.d/vim.sh
    /usr/bin/rvim
    /usr/bin/vim
    /usr/bin/vimdiff
    /usr/bin/vimtutor

    5、-qc查询已经安装的软件包中的配置文件所在的位置
    -c, --configfiles:List only configuration files.
    rpm -qc 包名
    例:
    [root@osker ~]# rpm -qc mlocate
    /etc/cron.daily/mlocate
    /etc/updatedb.conf

    6、-qd查询已经安装的软件包中的帮助文档
    -d, --docfiles:List only documentation files.
    rpm -qd 包名
    例:
    [root@osker ~]# rpm -qd  mlocate
    /usr/share/doc/mlocate-0.26/AUTHORS
    /usr/share/doc/mlocate-0.26/COPYING
    /usr/share/doc/mlocate-0.26/NEWS
    /usr/share/doc/mlocate-0.26/README
    /usr/share/man/man1/locate.1.gz
    /usr/share/man/man5/mlocate.db.5.gz
    /usr/share/man/man5/updatedb.conf.5.gz
    /usr/share/man/man8/updatedb.8.gz

    7、-qf(file)查询指定文件由哪个软件包生成
    -f, --file FILE:Query package owning FILE.
    例:
    [root@osker ~]# whereis ifconfig
    ifconfig: /usr/sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
    [root@osker ~]# rpm -qf  /usr/share/man/man8/ifconfig.8.gz
    net-tools-2.0-0.25.20131004git.el7.x86_64

    8、搜索
    [root@osker ~]# yum provides locate
    #查找locate命令所属包名
    Loaded plugins: fastestmirror
    Determining fastest mirrors
    ...     
    mlocate-0.26-8.el7.x86_64 : An utility for finding files by name
    Repo        : base
    Matched from:
    Filename    : /usr/bin/locate
    #安装mlocate
    [root@osker ~]# yum install -y mlocate
    Loaded plugins: fastestmirror
    ...
    Installed:
      mlocate.x86_64 0:0.26-8.el7
    Complete!
    [root@osker ~]# touch qiu
    [root@osker ~]# mkdir qiu1
    #创建测试文件和目录
    [root@osker ~]# ll
    total 4
    -rw-r--r-- 1 root root  0 Jan  2 09:41 osker
    -rw-r--r-- 1 root root  0 Jan  2 09:52 qiu
    drwxr-xr-x 2 root root  6 Jan  2 09:52 qiu1
    -rw-r--r-- 1 root root 17 Dec 31 16:43 sort.txt
    [root@osker ~]# updatedb
    #更新搜索数据库
    [root@osker ~]# locate qiu
    /root/qiu
    /root/qiu1


    rpm帮助
    [root@osker ~]# man rpm

  • 相关阅读:
    读书笔记之理想设计的特征
    一些javascript 变量声明的 疑惑
    LINQ 使用方法
    Google MySQL tool releases
    读书笔记之设计的层次
    EF之数据库连接问题The specified named connection is either not found in the configuration, not intended to be used with the Ent
    转载 什么是闭包
    javascript面向对象起步
    Tips
    数据结构在游戏中的应用
  • 原文地址:https://www.cnblogs.com/osker/p/12131850.html
Copyright © 2011-2022 走看看