ubuntu安装好了后首先要会下载和管理系统的软件包:ubuntu的软件管理方式是apt-get
- 安装软件包apt-get
harvey@ubuntu:/var/cache/apt$ which apt-get /usr/bin/apt-get #查找apt-get的位置发现这个程序是/usr/bin/apt-get发现这个程序是系统安装的时候,内置到系统的程序,是系统自带的 harvey@ubuntu:/var/cache/apt$ more /etc/apt/sources.list # deb cdrom:[Ubuntu 12.04.4 LTS _Precise Pangolin_ - Release amd64 (2014 0204)]/ dists/precise/main/binary-i386/ # deb cdrom:[Ubuntu 12.04.4 LTS _Precise Pangolin_ - Release amd64 (2014 0204)]/ dists/precise/restricted/binary-i386/ # deb cdrom:[Ubuntu 12.04.4 LTS _Precise Pangolin_ - Release amd64 (2014 0204)]/ precise main restricted
... #etc/apt/sources.list是网络上的软件repertory,可以手动在这里添加,当执行apt-get命令的时候,该程序会首先在本地repertory /var/cache/apt/archives查找安装包,没有找到就会根据source.list的地址查找网络软件仓库 harvey@ubuntu:/var/cache/apt$ ll /var/cache/apt/archives/ 总用量 313680 drwxr-xr-x 3 root root 12288 3月 16 13:50 ./ drwxr-xr-x 4 root root 4096 3月 16 13:50 ../ -rw-r--r-- 1 root root 6893170 3月 12 04:39 adobe-flashplugin_11.2.202.346-0precise1_amd64.deb
... #查看本地仓库的内容安装示例:
harvey@ubuntu:/var/cache/apt$ sudo apt-get install apt-file [sudo] password for harvey: 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 #安装apt-file安装包,会先分析软件包的依赖关系树 harvey@ubuntu:/var/cache/apt$ ll /var/cache/apt/archives/ |grep "apt-file" -rw-r--r-- 1 root root 25576 8月 6 2011 apt-file_2.5.0ubuntu1_all.deb #查找本地缓存中的apt-file安装包,发现找到了
apt-get clean---可以清理/var/share/apt/archives目录下的安装包;
- 查找安装包(实际上apt-get进行的也是dpkg安装包的安装,所以我们实际查询本地的安装包是是用dpkg查询的)
harvey@ubuntu:/var/cache/apt$ dpkg -l|more 期望状态=未知(u)/安装(i)/删除(r)/清除(p)/保持(h) | 状态=未安装(n)/已安装(i)/仅存配置(c)/仅解压缩(U)/配置失败(F)/不完全安 (H)/触发器等待(W)/触发器未决(T) |/ 错误?=(无)/须重装(R) (状态,错误:大写=故障) ||/ 名称 版本 描述 +++-==========================================-========================= ====================-=================================================== =========================== ii accountsservice 0.6.15-2ubuntu9.7 query and manipulate user account information ii acl 2.2.51-5ubuntu1 ...
#查询所有的本地安装包 harvey@ubuntu:/var/cache/apt$ dpkg -l|grep apt-file ii apt-file 2.5.0ubuntu1 search for files within Debian packages (command-line interface) harvey@ubuntu:/var/ca #查询指定的本地安装包 - 删除安装包命令sudo apt-get remove #
- 疑问待解决:
- dpkg -l不能查询ifconfig 等命令,难道ifconfig不是安装的命令吗?
- apt-get remove vi提示找不到安装包,但是我可以用vi的啊,这是什么情况?
harvey@ubuntu:/var/cache/apt$ sudo apt-get remove vi [sudo] password for harvey: 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 E: 未发现软件包 vi harvey@ubuntu:/var/cache/apt$ vi