Debian(debian前生,Ubuntu来世) 的软件分发模式就是 apt-get。所有可用软件列表信息存放在互联网的一些地方,一般称作 源(repositories)。
在终端
sudo gedit /etc/apt/sources.list
就可以看到类似
deb [web address] [distribution name][maincontribnon-free]
这样的内容。比如
deb http://in.archive.ubuntu.com/ubuntu breezy main restrcted
你可以从社区得到一些更好的源地址。每次修改源地址之后,终端执行
apt-get update
刷新本地的可安装软件列表数据。用下面命令搜索某软件安装信息
apt-cache search baseutils
安装软件直接输入下面命令,apt-get 会根据依赖关系,自动下在该程序需要的库文件等。
apt-get install baseutils
删除某软件使用
apt-get remove baseutils
得到该软件在源中的可用信息
apt-cache stats
比如返回:
Total package names : 22502 (900k)
Normal packages: 17632
Pure virtual packages: 281
Single virtual packages: 1048
Mixed virtual packages: 172
Missing: 3369
...
升级 ubuntu 版本时使用(慎重啊,兄弟,我在升级 breeze 到 dapper 时已经牺牲了)
apt-get dist-upgrade
每次 apt-get 安装软件都会把安装文件丢到 /var/cache/apt/archives/目录中,久而久之,大占空间,用这个命令删之
apt-get clean
也可以自动删除,如果系统认为安装包不有用或者不完整了的话
apt-get autoclean
dpkg
dpkg 是一个轻量级的软件管理工具。从网上下载的 .deb 文件使用如下命令安装
dpkg -i gedit-2.12.1.deb
删除软件包使用
dpkg -r gedit
注意删除的时候,只写软件名(安装需要完整 .deb 文件名)
下面命令(-P)删除更彻底,包括配置文件。(-r 不包括)
dpkg -P gedit
只是看软件包内容适用 -c 参数
dpkg -c gedit-2.12.1.deb
更多信息使用 -I 参数
dpkg -I gedit-2.12.1.deb
显示所有相关包
dpkg -l gcc*
比如返回
Desired=Unknown/Install/Remove/Purge/Hold
Status=Not/Installed/Config-files/Unpacked/Failed-config/.
/ Err?=(none)/Hold/Reinst-required/X=both-problems
/ Name Version Description
+++-===============-==============-========
ii gcc 4.0.1-3 The GNU C compiler
ii gcc-3.3-base 3.3.6-8ubuntu1 The GNU Compiler Colletio
un gcc-3.5 none (no description available)
un gcc-3.5-base none (no description available)
un gcc-3.5-doc none (no description available)
ii gcc-4.0 4.0.1-4ubuntu9 The GNU C compiler
...
In the above listing, the first 'i' denotes desired state which is install. The second 'i' denotes the actual state ie gcc is installed. The third column gives the error problems if any. The fourth, fifth and sixth column gives the name, version and description of the packages respectively. And gcc-3.5 is not installed on my machine. So the status is given as 'un' which is unknown not-installed.
-s 检查是否装过
dpkg -s gedit
Two days back, I installed beagle (a real time search tool based on Mono) on my machine. But I didn't have a clue about the location of the files as well as what files were installed along with beagle. That was when I used the -L option to get a list of all the files installed by the beagle package.
# dpkg -L beagle
Even better, you can combine the above command with grep to get a listing of all the html documentation of beagle.
# dpkg -L beagle | grep html$
These are just a small sample of the options you can use with dpkg utility. To know more about this tool, check its man page.
If you are alergic to excessive command line activities, then you may also use dselect which is a curses based menu driven front-end to the low level dpkg utility.
apt-get 的 GUI(图形界面) 版本
* Synaptic (纯图形界面,俗称 新立得)
* Aptitude (命令行界面)
xiyangyushu 于 2010-04-25 06:17:40发表:
我想问一下,使用
apt-get autoclean
之后,是一次性删除当前存在的残余包,还是以后产生的残余包在系统确认不需要之后都会自动删除?
chiyb 于 2010-04-24 14:29:07发表:
收了,谢谢楼主。