溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

linux如何查找軟件包得依賴關(guān)系

發(fā)布時(shí)間:2021-10-26 14:42:48 來源:億速云 閱讀:486 作者:小新 欄目:建站服務(wù)器

這篇文章主要介紹linux如何查找軟件包得依賴關(guān)系,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

apt-cache是一個(gè)apt軟件包管理工具,它可查詢apt的二進(jìn)制軟件包緩存文件。通過它我們可查詢軟件包的狀態(tài)信息。

apt-cache show package_name

顯示軟件的信息,包括版本號(hào),安裝狀態(tài)和包依賴關(guān)系等。

apt-cache search package_name

搜索軟件包,可用正則表達(dá)式。

apt-cache showpkg package_name

顯示軟件包的依賴關(guān)系信息。

apt-cache policy package_name

顯示軟件包的安裝狀態(tài)和版本信息。

apt-cache depends package_name

顯示指定軟件包所依賴的軟件包。

apt-cache rdepends package_name

顯示軟件包的反向依賴關(guān)系,即有什么軟件包需依賴你所指定的軟件包

-------

1.apt-cache showpkg
顯示軟件包的一些常規(guī)信息
例: apt-cache showpkg openssh

2.apt-cache stats
顯示相關(guān)的統(tǒng)計(jì)信息顯示相關(guān)的統(tǒng)計(jì)資訊

3.apt-cache dump
顯示緩存中的每個(gè)軟件包的簡(jiǎn)要描述信息

4.apt-cache unmet
顯示不符合一致性的依賴關(guān)系

5.apt-cache show
顯示指定軟件包的記錄信息。類似于rpm -qi

6.apt-cache search
查找軟件包,類似于rpm -qa|grep package_name
例: apt-cache search openssh

7.apt-cache depends
顯示軟件包的依賴性關(guān)系

8.apt-cache pkgnames
列出所有的軟件包

---

apt-get和apt-cache是Ubuntu Linux中的命令行下的包管理工具。 apt-get的GUI版本是Synaptic包管理器。本篇中我們會(huì)展示apt-get和apt-cache命令的15個(gè)不同例子。

linux如何查找軟件包得依賴關(guān)系

示例:1 列出所有可用包

linuxtechi@localhost:~$ apt-cache pkgnamesaccount-plugin-yahoojpceph-fusedvd+rw-toolse3gnome-commander-datagrub-gfxpayload-listsgweled.......................................

示例:2 用關(guān)鍵字搜索包

這個(gè)命令在你不確定包名時(shí)很有用,只要在apt-cache(LCTT 譯注:這里原文是apt-get,應(yīng)為筆誤)后面輸入與包相關(guān)的關(guān)鍵字即可。

linuxtechi@localhost:~$ apt-cache search "web server"apache2 - Apache HTTP Serverapache2-bin - Apache HTTP Server (binary files and modules)apache2-data - Apache HTTP Server (common files)apache2-dbg - Apache debugging symbolsapache2-dev - Apache HTTP Server (development headers)apache2-doc - Apache HTTP Server (on-site documentation)apache2-utils - Apache HTTP Server (utility programs for web servers)......................................................................

注意: 如果你安裝了“apt-file”包,我們就可以像下面那樣用配置文件搜索包。

linuxtechi@localhost:~$ apt-file search nagios.cfgganglia-nagios-bridge: /usr/share/doc/ganglia-nagios-bridge/nagios.cfgnagios3-common: /etc/nagios3/nagios.cfgnagios3-common: /usr/share/doc/nagios3-common/examples/nagios.cfg.gzpnp4nagios-bin: /etc/pnp4nagios/nagios.cfgpnp4nagios-bin: /usr/share/doc/pnp4nagios/examples/nagios.cfg

示例:3 顯示特定包的基本信息

linuxtechi@localhost:~$ apt-cache show postfixPackage: postfixPriority: optionalSection: mailInstalled-Size: 3524Maintainer: LaMont Jones <lamont@debian.org>Architecture: amd64Version: 2.11.1-1Replaces: mail-transport-agentProvides: default-mta, mail-transport-agent.....................................................

示例:4 列出包的依賴

linuxtechi@localhost:~$ apt-cache depends postfixpostfix Depends: libc6 Depends: libdb5.3 Depends: libsasl2-2 Depends: libsqlite3-0 Depends: libssl1.0.0 |Depends: debconf Depends: <debconf-2.0> cdebconf debconf Depends: netbase Depends: adduser Depends: dpkg............................................

示例:5 使用apt-cache顯示緩存統(tǒng)計(jì)

linuxtechi@localhost:~$ apt-cache stats Total package names: 60877 (1,218 k)Total package structures: 102824 (5,758 k) Normal packages: 71285 Pure virtual packages: 1102 Single virtual packages: 9151 Mixed virtual packages: 1827 Missing: 19459Total distinct versions: 74913 (5,394 k)Total distinct descriptions: 93792 (2,251 k)Total dependencies: 573443 (16.1 M)Total ver/file relations: 78007 (1,872 k)Total Desc/File relations: 93792 (2,251 k)Total Provides mappings: 16583 (332 k)Total globbed strings: 171 (2,263 )Total dependency version space: 2,665 kTotal slack space: 37.3 kTotal space accounted for: 29.5 M

示例:6 使用 “apt-get update” 更新倉庫

使用命令“apt-get update”, 我們可以重新從源倉庫中同步文件索引。包的索引從“/etc/apt/sources.list”中檢索。

linuxtechi@localhost:~$ sudo apt-get update Ign http://extras.ubuntu.com utopic InRelease Hit http://extras.ubuntu.com utopic Release.gpg Hit http://extras.ubuntu.com utopic Release Hit http://extras.ubuntu.com utopic/main Sources Hit http://extras.ubuntu.com utopic/main amd64 Packages Hit http://extras.ubuntu.com utopic/main i386 Packages Ign http://in.archive.ubuntu.com utopic InRelease Ign http://in.archive.ubuntu.com utopic-updates InRelease Ign http://in.archive.ubuntu.com utopic-backports InRelease ................................................................

示例:7 使用apt-get安裝包

linuxtechi@localhost:~$ sudo apt-get install icinga

上面的命令會(huì)安裝叫“icinga”的包。

示例:8 升級(jí)所有已安裝的包

linuxtechi@localhost:~$ sudo apt-get upgrade

示例:9 更新特定的包

在apt-get命令中的“install”選項(xiàng)后面接上“-only-upgrade”用來更新一個(gè)特定的包,如下所示:

linuxtechi@localhost:~$ sudo apt-get install filezilla --only-upgrade

示例:10 使用apt-get卸載包

linuxtechi@localhost:~$ sudo apt-get remove skype

上面的命令只會(huì)刪除skype包,如果你想要?jiǎng)h除它的配置文件,在apt-get命令中使用“purge”選項(xiàng)。如下所示:

linuxtechi@localhost:~$ sudo apt-get purge skype

我們可以結(jié)合使用上面的兩個(gè)命令:

linuxtechi@localhost:~$ sudo apt-get remove --purge skype

示例:11 在當(dāng)前的目錄中下載包

linuxtechi@localhost:~$ sudo apt-get download icingaGet:1 http://in.archive.ubuntu.com/ubuntu/ utopic/universe icinga amd64 1.11.6-1build1 [1,474 B]Fetched 1,474 B in 1s (1,363 B/s)

上面的目錄會(huì)把icinga包下載到你的當(dāng)前工作目錄。

示例:12 清理本地包占用的磁盤空間

linuxtechi@localhost:~$ sudo apt-get clean

上面的命令會(huì)清空apt-get所下載的包占用的磁盤空間。

我們也可以使用“autoclean”選項(xiàng)來代替“clean”,兩者之間主要的區(qū)別是autoclean清理不再使用且沒用的下載。

linuxtechi@localhost:~$ sudo apt-get autocleanReading package lists... DoneBuilding dependency treeReading state information... Done

示例:13 使用“autoremove”刪除包

當(dāng)在apt-get命令中使用“autoremove”時(shí),它會(huì)刪除為了滿足依賴而安裝且現(xiàn)在沒用的包。

linuxtechi@localhost:~$ sudo apt-get autoremove icinga

示例:14 顯示包的更新日志

linuxtechi@localhost:~$ sudo apt-get changelog apache2Get:1 Changelog for apache2 (http://changelogs.ubuntu.com/changelogs/pool/main/a/apache2/apache2_2.4.10-1ubuntu1/changelog) [195 kB]Fetched 195 kB in 3s (60.9 kB/s)

上面的命令會(huì)下載apache2的更新日志,并在你屏幕上分頁顯示。

示例:15 使用 “check” 選項(xiàng)顯示損壞的依賴關(guān)系

linuxtechi@localhost:~$ sudo apt-get checkReading package lists... DoneBuilding dependency treeReading state information... Done

以上是“l(fā)inux如何查找軟件包得依賴關(guān)系”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI