1. 程式人生 > 其它 >dpkg 刪除軟體_dpkg 命令教程

dpkg 刪除軟體_dpkg 命令教程

技術標籤:dpkg 刪除軟體

dpkg是Debian和基於Debian的系統中的主要軟體包管理程式,用於安裝,構建,刪除和管理軟體包。

安裝軟體包

要安裝“.deb”軟體包,請使用帶有“-i”選項的命令。例如,要安裝名為“htop_2.2.0-1+b1_amd64.deb”的“.deb”軟體包,請使用以下命令。

[email protected]:~# [email protected]:~# dpkg -i htop_2.2.0-1+b1_amd64.deb Selecting previously unselected package htop.(Reading database ... 27602 files and directories currently installed.)Preparing to unpack htop_2.2.0-1+b1_amd64.deb ...Unpacking htop (2.2.0-1+b1) ...Setting up htop (2.2.0-1+b1) ...Processing triggers for mime-support (3.62) ...Processing triggers for man-db (2.8.5-2) 
[email protected]
:~#

列出所有已安裝的軟體包

要檢視和列出所有已安裝的軟體包,請在命令中使用“-l”選項。

[email protected]:~# dpkg -l

要檢視已安裝或未安裝的特定軟體包,請使用選項“-l”以及軟體包名稱。例如,檢查是否安裝了 htop軟體包。

[email protected]:~# dpkg -l htopDesired=Unknown/Install/Remove/Purge/Hold| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)||/ Name           Version      Architecture Description+++-==============-============-============-=================================ii  htop           2.2.0-1+b1   amd64        interactive processes 
[email protected]
:~#

刪除安裝的軟體包

要刪除“.deb”軟體包,必須指定軟體包名稱“htop”,而不是原始名稱“htop_2.2.0-1+b1_amd64.deb”,“-r”選項用於刪除/解除安裝軟體包。

[email protected]:~# dpkg -r htop(Reading database ... 27613 files and directories currently installed.)Removing htop (2.2.0-1+b1) ...Processing triggers for man-db (2.8.5-2) ...Processing triggers for mime-support (3.62) 
[email protected]
:~#

使用'p'選項代替'r',將刪除軟體包以及配置檔案。'r'選項將僅刪除軟體包,而不會刪除配置檔案。

[email protected]:~# dpkg -P htop(Reading database ... 27613 files and directories currently installed.)Removing htop (2.2.0-1+b1) ...Processing triggers for man-db (2.8.5-2) ...Processing triggers for mime-support (3.62) [email protected]:~#

檢視軟體包內容

要檢視軟體包的內容,使用“-c”選項,如圖所示,該命令將以長列表格式顯示“.deb”軟體包的內容。

[email protected]:~# dpkg -c htop_2.2.0-1+b1_amd64.deb drwxr-xr-x root/root         0 2018-05-15 16:55 ./drwxr-xr-x root/root         0 2018-05-15 16:55 ./usr/drwxr-xr-x root/root         0 2018-05-15 16:55 ./usr/bin/-rwxr-xr-x root/root    185048 2018-05-15 16:55 ./usr/bin/htopdrwxr-xr-x root/root         0 2018-05-15 16:55 ./usr/share/drwxr-xr-x root/root         0 2018-05-15 16:55 ./usr/share/applications/-rw-r--r-- root/root      2461 2018-05-15 16:55 ./usr/share/applications/htop.desktopdrwxr-xr-x root/root         0 2018-05-15 16:55 ./usr/share/doc/drwxr-xr-x root/root         0 2018-05-15 16:55 ./usr/share/doc/htop/-rw-r--r-- root/root        19 2018-04-11 08:13 ./usr/share/doc/htop/AUTHORS-rw-r--r-- root/root      2192 2018-04-11 08:13 ./usr/share/doc/htop/README-rw-r--r-- root/root       212 2018-05-15 16:55 ./usr/share/doc/htop/changelog.Debian.amd64.gz-rw-r--r-- root/root      5762 2018-05-15 16:55 ./usr/share/doc/htop/changelog.Debian.gz-rw-r--r-- root/root      8071 2018-04-11 08:13 ./usr/share/doc/htop/changelog.gz-rw-r--r-- root/root      1276 2018-04-27 02:59 ./usr/share/doc/htop/copyrightdrwxr-xr-x root/root         0 2018-05-15 16:55 ./usr/share/man/drwxr-xr-x root/root         0 2018-05-15 16:55 ./usr/share/man/man1/-rw-r--r-- root/root      4844 2018-05-15 16:55 ./usr/share/man/man1/htop.1.gzdrwxr-xr-x root/root         0 2018-05-15 16:55 ./usr/share/pixmaps/-rw-r--r-- root/root      3657 2018-05-15 16:55 ./usr/share/pixmaps/[email protected]:~#

檢視軟體是否安裝

在軟體包名稱中使用“-s”選項,將顯示是否已安裝。

[email protected]:~# dpkg -s htop dpkg-query: package 'htop' is not installed and no information is availableUse dpkg --info (= dpkg-deb --info) to examine archive [email protected]:~# dpkg -i htop_2.2.0-1+b1_amd64.deb Selecting previously unselected package htop.(Reading database ... 27602 files and directories currently installed.)Preparing to unpack htop_2.2.0-1+b1_amd64.deb ...Unpacking htop (2.2.0-1+b1) ...Setting up htop (2.2.0-1+b1) ...Processing triggers for mime-support (3.62) ...Processing triggers for man-db (2.8.5-2) [email protected]:~# dpkg -s htop Package: htopStatus: install ok installedPriority: optionalSection: utilsInstalled-Size: 225Maintainer: Daniel Lange Architecture: amd64Source: htop (2.2.0-1)Version: 2.2.0-1+b1Depends: libc6 (>= 2.15), libncursesw6 (>= 6), libtinfo6 (>= 6)Suggests: lsof, straceDescription: interactive processes viewer Htop is an ncursed-based process viewer similar to top, but it allows one to scroll the list vertically and horizontally to see all processes and their full command lines. . Tasks related to processes (killing, renicing) can be done without entering their PIDs.Homepage: https://hisham.hm/htop/[email protected]:~#

檢視軟體安裝位置

從軟體包名稱檢視安裝到系統的位置。

[email protected]:~# dpkg -L htop/./usr/usr/bin/usr/bin/htop/usr/share/usr/share/applications/usr/share/applications/htop.desktop/usr/share/doc/usr/share/doc/htop/usr/share/doc/htop/AUTHORS/usr/share/doc/htop/README/usr/share/doc/htop/changelog.Debian.amd64.gz/usr/share/doc/htop/changelog.Debian.gz/usr/share/doc/htop/changelog.gz/usr/share/doc/htop/copyright/usr/share/man/usr/share/man/man1/usr/share/man/man1/htop.1.gz/usr/share/pixmaps/usr/share/pixmaps/[email protected]:~#

從目錄安裝所有軟體

遞迴地安裝在指定目錄及其所有子目錄中找到的所有匹配模式“ *.deb”的常規檔案。可以將其與“-R”和“–install”選項一起使用。例如,我將從名為“debpackages”的目錄中安裝所有“.deb”軟體包。

[email protected]:~#dpkg-R--installnginx/

開啟軟體包但不配置

使用動作“–unpack”將開啟軟體包的包裝,但不會安裝或配置。

[email protected]:~# dpkg --unpack htop_2.2.0-1+b1_amd64.deb Selecting previously unselected package htop.(Reading database ... 27602 files and directories currently installed.)Preparing to unpack htop_2.2.0-1+b1_amd64.deb ...Unpacking htop (2.2.0-1+b1) ...Processing triggers for mime-support (3.62) ...Processing triggers for man-db (2.8.5-2) [email protected]:~#ls

重新配置解包的軟體包

選項“–configure”將重新配置已經解壓縮的軟體包。

[email protected]:~# dpkg --configure htopSetting up htop (2.2.0-1+b1) [email protected]:~#

替換可用包資訊

“–-update-avail”選項將舊資訊替換為Packages檔案中的可用資訊。

[email protected]:~# dpkg –-update-avail bmon

刪除軟體包中現有的可用資訊

“-clear-avaial”操作將刪除有關可用軟體包的當前資訊。

[email protected]:~# dpkg --clear-avail

刪除不可用軟體包

[email protected]:~# dpkg --forget-old-unavail

獲取有關dpkg的所有幫助

“–help”選項將顯示dpkg命令的可用選項列表。

[email protected]:~# dpkg --helpUsage: dpkg [ ...] Commands:  -i|--install       <.deb file name>... | -R|--recursive ...  --unpack           <.deb file name>... | -R|--recursive ...  -A|--record-avail  <.deb file name>... | -R|--recursive ...  --configure        ... | -a|--pending  --triggers-only    ... | -a|--pending  -r|--remove        ... | -a|--pending  -P|--purge         ... | -a|--pending  -V|--verify [...]       Verify the integrity of package(s).  --get-selections [...]  Get list of selections to stdout.  --set-selections                 Set package selections from stdin.  --clear-selections               Deselect every non-essential package.  --update-avail [] Replace available packages info.  --merge-avail []  Merge with info from file.  --clear-avail                    Erase existing available info.  --forget-old-unavail             Forget uninstalled unavailable pkgs.  -s|--status [...]       Display package status details.  -p|--print-avail [...]  Display available version details.  -L|--listfiles ...      List files 'owned' by package(s).  -l|--list [...]         List packages concisely.  -S|--search ...         Find package(s) owning file(s).  -C|--audit [...]        Check for broken package(s).  --yet-to-unpack                  Print packages selected for installation.  --predep-package                 Print pre-dependencies to unpack.  --add-architecture         Add  to the list of architectures.  --remove-architecture      Remove  from the list of architectures.  --print-architecture             Print dpkg architecture.  --print-foreign-architectures    Print allowed foreign architectures.  --assert-               Assert support for the specified feature.  --validate-      Validate a 's .  --compare-versions    Compare version numbers - see below.  --force-help                     Show help on forcing.  -Dh|--debug=help                 Show help on debugging.  -?, --help                       Show this help message.      --version                    Show the version.Assertable features: support-predepends, working-epoch, long-filenames,  multi-conrep, multi-arch, versioned-provides.Validatable things: pkgname, archname, trigname, version.Use dpkg with -b, --build, -c, --contents, -e, --control, -I, --info,  -f, --field, -x, --extract, -X, --vextract, --ctrl-tarfile, --fsys-tarfileon archives (type dpkg-deb --help).Options:  --admindir=     Use  instead of /var/lib/dpkg.  --root=         Install on a different root directory.  --instdir=      Change installation dir without changing admin dir.  --path-exclude=   Do not install paths which match a shell pattern.  --path-include=   Re-include a pattern after a previous exclusion.  -O|--selected-only         Skip packages not selected for install/upgrade.  -E|--skip-same-version     Skip packages whose same version is installed.  -G|--refuse-downgrade      Skip packages with earlier version than installed.  -B|--auto-deconfigure      Install even if it would break some other package.  --[no-]triggers            Skip or force consequential trigger processing.  --verify-format=   Verify output format (supported: 'rpm').  --no-debsig                Do not try to verify package signatures.  --no-act|--dry-run|--simulate                             Just say what we would do - don't do it.  -D|--debug=         Enable debugging (see -Dhelp or --debug=help).  --status-fd             Send status change updates to file descriptor .  --status-logger=  Send status change updates to 's stdin.  --log=           Log status changes and actions to .  --ignore-depends=,...                             Ignore dependencies involving .  --force-...                Override problems (see --force-help).  --no-force-...|--refuse-...                             Stop when problems encountered.  --abort-after           Abort after encountering  errors.Comparison operators for --compare-versions are:  lt le eq ne ge gt       (treat empty version as earlier than any version);  lt-nl le-nl ge-nl gt-nl (treat empty version as later than any version);  < << <= = >= >> >       (only for compatibility with control file syntax).Use 'apt' or 'aptitude' for user-friendly package [email protected]:~#

----------END----------

5f2d056af56882562435badd4fbfcd71.gif