歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> debian中如何查看軟件包是否已經安裝和如何安裝、卸載軟件

debian中如何查看軟件包是否已經安裝和如何安裝、卸載軟件

日期:2017/2/27 15:46:07   编辑:Linux教程
1. 確定軟件包是否安裝
如果您不確定某個軟件包是否已經安裝,可以使用 dpkg 的 -l (L的小寫) 選項:
$ dpkg -l zsh No packages found matching zsh.

上面結果這表明 zsh 沒有 安裝。

2. 搜索軟件包
可以使用 apt-cache 命令和它的 search 子命令來搜索軟件包: zsh,如清單 1 所示。
使用 apt-cache 搜索 zsh
$ apt-cache search zsh kdesdk-scripts - scripts and data files for development zsh - A shell with lots of features zsh-dbg - A shell with lots of features (debugging symbols) zsh-dev - A shell with lots of features (development files) zsh-doc - zsh documentation - info/HTML format csh - Shell with C-like syntax, standard login shell on BSD systems draai - A command-line music player for MPD fatrat-czshare - fatrat plugin allowing download and upload to czshare grml-shlib - Generic shell library used in grml scripts tucan - Download and upload manager for 1-Click Hosters viewglob - A graphical display of directories referenced at the shell prompt zsh-beta - A shell with lots of features (dev tree) zsh-beta-doc - zsh beta documentation - info/HTML format zsh-lovers - tips, tricks and examples for the zsh zsh-static - A shell with lots of features (static link) zshdb - debugger for Z-Shell scripts
該輸出給出了相關聯的幾個軟件包,包含了 zsh 字符串。如果您想安裝 Z shell,zsh 包就是您要的。(您可能還要安裝 zsh-doc 和其他的包,但現在安裝 zsh 就可以了。)

3. 使用 apt安裝一個軟件包
要從一個 APT 代碼庫安裝,可以使用 apt-get 和它的 install 選項,如清單 2 所示。
通過apt安裝 zsh
$ sudo apt-get install zsh Reading package lists... Done Building dependency tree        Reading state information... Done Suggested packages:   zsh-doc The following NEW packages will be installed:   zsh 0 upgraded, 1 newly installed, 0 to remove and 59 not upgraded. Need to get 4,504 kB of archives. After this operation, 14.1 MB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu/ natty/main zsh amd64 4.3.11-4ubuntu2.is.3ubuntu1 [4,504 kB] Fetched 4,504 kB in 7s (643 kB/s)                                               Selecting previously deselected package zsh. (Reading database ... 146971 files and directories currently installed.) Unpacking zsh (from .../zsh_4.3.11-4ubuntu2.is.3ubuntu1_amd64.deb) ... Processing triggers for menu ... Processing triggers for man-db ... Setting up zsh (4.3.11-4ubuntu2.is.3ubuntu1) ... update-alternatives: using /bin/zsh4 to provide /bin/zsh (zsh) in auto mode. update-alternatives: using /bin/zsh4 to provide /bin/rzsh (rzsh) in auto mode. update-alternatives: using /bin/zsh4 to provide /bin/ksh (ksh) in auto mode. Processing triggers for menu ...
注意: 由於 debian 的安全模式,影響軟件包安裝的命令前面必須加 sudo。某些發行版以及修改了缺省安全模式的 debian,可以忽略 sudo,但需要從 root 用戶執行命令。

apt-get install 命令搜索並安裝 zsh。如果有任何依賴包沒有裝,該命令同時安裝這些包。

4. 確定軟件包的狀態

使用 -s 或 --status選項驗證 zsh 是否已經安裝。見清單 3。
zsh 是否安裝
$ dpkg -s zsh Package: zsh Status: install ok installed Priority: optional Section: shells Installed-Size: 13732 Maintainer: Ubuntu Developers ([email protected]) Architecture: amd64 Version: 4.3.11-4ubuntu2.is.3ubuntu1 Depends: libc6 (>= 2.4), libcap2 (>= 2.10), libncursesw5 (>= 5.6+20070908) Recommends: libc6 (>= 2.11), libpcre3 (>= 8.10) Suggests: zsh-doc Conffiles:  /etc/zsh/zlogin 48032df2ace0977f2491b016e3c421a3  /etc/zsh/zlogout b73789c3e790b855302ce10ca076037a  /etc/zsh/zprofile 58c4f65d775c055b5d80b67c1bd12838  /etc/zsh/zshenv 5a8a0ff4f6ff945a5aa6ba7f6f1e8c97  /etc/zsh/zshrc e069ba51ba293da1aeddd5779324df19  /etc/zsh/newuser.zshrc.recommended dac3563a2ddd13e8027b1861d415f3d4 Description: A shell with lots of features  Zsh is a UNIX command interpreter (shell) usable as an  interactive login shell and as a shell script command  processor. Of the standard shells, zsh most closely resembles  ksh but includes many enhancements. Zsh has command-line editing,  built-in spelling correction, programmable command completion,  shell functions (with autoloading), a history mechanism, and a  host of other features. Homepage: http://www.zsh.org/ Original-Maintainer: Debian Zsh Maintainers ([email protected])
This package is now installed, and you can see information on its version, its dependencies, who created it, and so on.

5. 列出軟件包相關的文件
To learn which files were installed as part of the zsh package, use the -L option to dpkg:
$ dpkg -L zsh
The resulting output is quite lengthy, because the package includes many individual files. If you wanted to search for a particular file, you might want to pipe the output through grep or less.

6. 卸載軟件包
For the final exercise, uninstall zsh (unless you want to try it and perhaps even use it regularly). To do so, use apt-get and its remove or purge command. Listing 4 shows the code.
$ sudo apt-get remove zsh Reading package lists... Done Building dependency tree        Reading state information... Done The following packages will be REMOVED:   zsh 0 upgraded, 0 newly installed, 1 to remove and 59 not upgraded. After this operation, 14.1 MB disk space will be freed. Do you want to continue [Y/n]? y (Reading database ... 148096 files and directories currently installed.) Removing zsh ... Processing triggers for man-db ... Processing triggers for menu ...
Alternatively, you could use dpkg and its -r/--remove or -P/--purge option. Listing 5 shows the code.

使用 dpkg 卸載
$ sudo dpkg -P zsh (Reading database ... 148096 files and directories currently installed.) Removing zsh ... Purging configuration files for zsh ... Processing triggers for man-db ... Processing triggers for menu ...
Copyright © Linux教程網 All Rights Reserved