debian linux 中如何查看软件包是否已经安装和如何安装、卸载软件

练习 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 ([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.

清单 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 ...
时间: 2024-08-02 12:49:29

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

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

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

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

查看 一个文件的 最初创建时间: Linux中如何查看文件的最初创建时间 linux 目前Linux没有直接查看创建文件的命令,你只能通过文件是否被修改过来进行判断. //查看代码stat 文件名 //例如:[[email protected] ~]# stat 1.txt  File: "1.txt"  Size: 18              Blocks: 8          IO Block: 4096   普通文件Device: fd00h/64768d    Inode

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

add by zhj:-/+ buffers/cache行的free列就是实际未使用的内存.free -m中的参数-m是指以MB为单元输出数据 原文:http://liustb.blog.163.com/blog/static/1337080192011718112434416/ free命令用来查看内存的使用情况,与Top命令相比,开销较小. $free –m total          used        free        shared         buffers      

在linux中如何查看常用命令的源码

Linux中有很多很棒的工具,我们可以在平常的使用中,可以采用查看源码的方式来学习它.以下就以uptime为例来说一说吧. 1.首先,我们要查询一下uptime是由哪个package提供的 #rpm -qf $(which uptime) procps-3.2.8-33.0.1.el6.x86_64 2.接着,我们要来下载带源码的rpm包了,在确保你的OS能连接外网并配置好yum源后,就可以用下面的命令来完成了. yumdownloader --source procps 3.解压 rpm -i

Linux中如何查看进程和控制进程

查看进程的命令如下:ps命令--查看静态的进程统计信息(一般结合选项使用 ps aux 或 ps -elf 命令)建议使用 ps -elf 查询,输出的信息更详细些,包括 PPID (对应的父进程 的PID 号) 以上输出信息中,第一行为列表标题,其中各字段的含义描述如下. USER:启动该进程的用户账号名称: PID:该进程在系统中的数字 ID 号,在当前系统中是唯一的: %CPU:CPU占用的百分比: %MEM:内存占用的百分比: VSZ:占用虚拟内存(swap 空间)的大小: RSS:占用

LINUX中如何查看某个端口是否被占用

之前查询端口是否被占用一直搞不明白,问了好多人,终于搞懂了,现在总结下: 1.netstat  -anp  |grep   端口号 如下,我以3306为例,netstat  -anp  |grep  3306(此处备注下,我是以普通用户操作,故加上了sudo,如果是以root用户操作,不用加sudo即可查看),如下图1: 图1 图1中主要看监控状态为LISTEN表示已经被占用,最后一列显示被服务mysqld占用,查看具体端口号,只要有如图这一行就表示被占用了. 2.netstat   -nult

Linux中查看进程的多线程pstree, ps -L

Linux中查看进程的多线程 在SMP系统中,我们的应用程序经常使用多线程的技术,那么在Linux中如何查看某个进程的多个线程呢? 本文介绍3种命令来查看Linux系统中的线程(LWP)的情况:在我的系统中,用qemu-system-x86_64命令启动了一个SMP的Guest,所以有几个qemu的线程,以此为例来说明. 1. pstree 命令,查看进程和线程的树形结构关系.  BASH 1 2 3 4 5 [root@jay-linux ~]# pstree | grep qemu |-gn

Linux中查看进程的多线程

在SMP系统中,我们的应用程序经常使用多线程的技术,那么在Linux中如何查看某个进程的多个线程呢? 本文介绍3种命令来查看Linux系统中的线程(LWP)的情况: 在我的系统中,用qemu-system-x86_64命令启动了一个SMP的Guest,所以有几个qemu的线程,以此为例来说明. 1. pstree 命令 查看进程和线程的树形结构关系 [[email protected] ~]# pstree | grep qemu |-terminal-+-bash---qemu-sys---2

linux中管理包的apt和dpkg命令用法

1,apt-get命令 apt-get是debian,ubuntu发行版的包管理工具,与红帽中的yum工具非常类似,适用于deb包管理式的操作系统,主要用于自动从互联网的软件仓库中搜索.安装.升级.卸载软件或操作系统.apt-get在安装包的时候是根据/etc/apt/sources.list文件中指定的源来寻找的安装包,你可以根据自己的需要对这个文件进行修改. 详情如下: sudo apt-get install package 安装包 sudo apt-get install package