练习 1 方案:确定软件包是否安装

如果您不确定某个软件包是否已经安装,可以使用 dpkg 的 -l (L的小写) 选项:

$ dpkg -l zsh No packages found matching zsh. 

上面结果这表明 zsh 没有 安装。

练习 2 的方案. 搜索软件包

可以使用 apt-cache 命令和它的 search 子命令来搜索软件包: zsh,如清单 1 所示。

清单 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 所示。

清单 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。

清单 3. 验证 zsh 是否安装

     $ dpkg -s zsh Package: zsh Status: install ok installed Priority: optional Section: shells Installed-Size: 13732 Maintainer: Ubuntu Developers (ubuntu-devel-discuss@lists.ubuntu.com) 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 (pkg-zsh-devel@lists.alioth.debian.org) 

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.

清单 4. 卸载 zsh

     $ 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.

清单 5. 使用 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 ...

debian linux 中如何查看软件包是否已经安装和如何安装、卸载软件的更多相关文章

  1. reinstall_xbt: Linux中如何查看文件的最初创建时间

    Linux中如何查看文件的最初创建时间 与文件相关的几个时间: 1.访问时间,读一次这个文件的内容,这个时间就会更新.比如对这个文件使用more命令.ls.stat命令都不会修改文件的访问时间.   ...

  2. Linux中如何查看文件的最初创建时间

    查看 一个文件的 最初创建时间: Linux中如何查看文件的最初创建时间  linux     目前Linux没有直接查看创建文件的命令,你只能通过文件是否被修改过来进行判断. //查看代码stat  ...

  3. centos linux中怎么查看和修改计算机名/etc/sysconfig/network

    centos linux中怎么查看和修改计算机名 查看计算机名:在终端输入hostname 修改的话 hostname +计算机名(重启后失效)要永久修改的话要修改配置文件/etc/sysconfig ...

  4. linux中可以查看端口占用的方法

    在自己搭建的服务器中,经常容易出现端口被占用的问题,那么怎么知道自己的端口是否被占用了呢? 可以使用下面的方法: linux中可以查看端口占用的方法. netstat -ant | grep 80 ( ...

  5. 在 Linux 中自动生成 Cordova/Phonegap for Android 的 APK 安装程序

    在 Linux 中自动生成 Cordova/Phonegap for Android 的 APK 安装程序 本贴首发于: http://xuekaiyuan.com/forum.php?mod=vie ...

  6. 在linux中怎么查看错误日志

    cat或者tail -f命令 日 志 文 件 说 明 /var/log/message 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一/var/log/secure 与安全 ...

  7. Linux中内存查看命令free详解(转)

    add by zhj:说了那么多,其实看第一行就足够了,free项就是未使用的内存.其实,我是感觉压根就没必要 使用free命令,用top代替就行了 原文:http://liustb.blog.163 ...

  8. Linux中如何查看文件夹的大小

    直接查看当前文件夹的大小: du –sh 只看文件夹的名字里包含某字符串的子文件夹的大小: du –h –d 1 | grep "BACKEND" 我的linux系统被阉割的比较厉 ...

  9. Linux中内容查看命令"大PK"

    众所周知linux中命令cat.more.less均可用来查看文件内容,当然还有我们"非主流"的vim以及使用较少的head.tail.tac. 下面我将介绍各种命令的用法及对比. ...

随机推荐

  1. ajax分页实现,jquery.pagination.js

    1.前台使用ajax无刷新分页,主要需要生成分页的工具条,这里使用的是jquery.pagination.js 插件参数可以参考----张龙豪-jquery.pagination.js分页 下面贴出代 ...

  2. component object model(组件对象模型)

    通常,COM是以 win32动态链接库(dll)或可执行文件(exe)的形式发布. 在COM中,接口就是一切,对于客户来说,一个组件就是一个接口集.COM接口是一个包含一个函数指针数组的内存结构. 组 ...

  3. 进阶C#?

    玩了几年的编程了,大四了.本来不想考研,我老师找我谈几次,最近准备考研.从一开始玩java,接触.net中的C#,aps.net,到接触linux,太多太多了. 本来我们专业不是纯计算机的,但是和计算 ...

  4. 如何搭建DHCP及DHCP中继服务器

    当局域网中有大量的主机时,如果逐台设置ip地址.默认网关.dns服务器地址时等网络参数,显然是一个费力也未必讨好的方法,这时使用DHCP的方式分发ip地址,能够动态配置各客户机的网络地址参数,大大减轻 ...

  5. DHCP租约时间工作原理

    问题:    很多用户在使用路由器的DHCP服务器过程中都有一个疑问,DHCP有个设置项目是设置DHCP地址的租约时间,如果设置的比较短,是否会出现租约时间到了以后会重新去获取ip地址,造成用户断网? ...

  6. 最全的ORACLE-SQL笔记

    -- 首先,以超级管理员的身份登录oracle sqlplus sys/bjsxt as sysdba --然后,解除对scott用户的锁 alter user scott account unloc ...

  7. angularjs使用directive实现倒计时按钮

    前不久在做一个彩票的项目时,有一个手动开奖的需求.所以有了这个倒计时按钮.下面分享下具体的代码: 效果: 代码: App.directive('timerBtn', function() { // 倒 ...

  8. Class类相关

    Class类是java.lang包中的类,该类的实例可以帮助程序创建其他类的实例或者取得其他类的对象的内部信息 使用class类获得一个类相关的class类(注意得到的是class类,不是相关的类) ...

  9. 关于js闭包杂记

    闭包:一个函数oneF里return了另一个函数innerF,然后在oneF外面运行了函数innerF,如果innerF里有用到在oneF里定义的变量,则此时依然可以引用到, 但是变量值不是定义函数i ...

  10. 准备开发一个基于canvas的图表库,记录一些东西(一)

    开源的图表库已经有很多了,这里从头写个自己的,主要还是 提高自己js的水平,增加复杂代码组织的经验 首先写一个画图的库,供以后画图表使用.经过2天的开发,算是能拿出点东西了,虽然功能还很弱,但是有了一 ...