Apt-* 命令

啊哈, 终于到了Debian系列啦~

apt-cache search 搜索软件包

  1. apt-cache search ^apache2$
  2. apache2 - Apache HTTP Server

这个例子搜索了apache2这个软件, 可以看到, 支持正则表达式哦~

dpkg -l列出当前安装的软件包

其实也不仅列出了安装的软件包, 还列出了曾经安装过, 现在没有完全卸载的软件包, 前面有几个标识符, 比如i,r:

  1. apache2 - Apache HTTP Server
  2. dpkg -l
  3. Desired=Unknown/Install/Remove/Purge/Hold
  4. | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
  5. |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
  6. ||/ Name Version Architecture Description
  7. +++-====================================-=======================-=======================-=============================================================================
  8. ii account-plugin-aim 3.12.10-0ubuntu2 amd64 Messaging account plugin for AIM
  9. ii account-plugin-facebook 0.12+15.10.20150723-0ub all GNOME Control Center account plugin for single signon - facebook
  10. ii account-plugin-flickr 0.12+15.10.20150723-0ub all GNOME Control Center account plugin for single signon - flickr
  11. ii account-plugin-google 0.12+15.10.20150723-0ub all GNOME Control Center account plugin for single signon
  12. ii account-plugin-jabber 3.12.10-0ubuntu2 amd64 Messaging account plugin for Jabber/XMPP
  13. ii account-plugin-salut 3.12.10-0ubuntu2 amd64 Messaging account plugin for Local XMPP (Salut)
  14. ii account-plugin-yahoo 3.12.10-0ubuntu2 amd64 Messaging account plugin for Yahoo!
  15. ii accountsservice 0.6.40-2ubuntu5 amd64 query and manipulate user account information
  16. ii acct 6.5.5-2.1ubuntu1 amd64 The GNU Accounting utilities for process and login accounting
  17. ii ack-grep 2.14-4 all grep-like program specifically for large source trees
  18. ii acl 2.2.52-2 amd64 Access control list utilities
  19. ii acpi-support 0.142 amd64 scripts for handling many ACPI events
  20. ...
  21. ...
  22. ...

可以看到, 乱七八糟一大堆…

这个命令也能安装软件.dpkg -i packge_name.deb

apt-get install 安装软件

也很简单啊, 只要把你需要安装的软件告诉他, 然后他就会按照依赖关系把需要的包一个一个都给装好:

  1. $ sudo apt-get install apache2
  2. [sudo] password for ramesh:
  3. The following NEW packages will be installed:
  4. apache2 apache2-mpm-worker apache2-utils
  5. apache2.2-common libapr1 libaprutil1 libpq5
  6. 0 upgraded, 7 newly installed, 0 to remove and 26 not upgraded.

apt-get remove 卸载软件

  1. $ sudo apt-get purge apache2
  2. (or)
  3. $ sudo apt-get remove apache2

两者都可以卸载, 区别是什么? 第一个是彻底卸载, 包括各种配置文件,可以理解为apt-get remove apache2* 第二个只是移除二进制文件, 单纯的把apache2卸载.

除此之外, 还有apt-get update, apt-get upgrade, apt-get dist-upgrade等一系列命令… 想知道他们都是什么吗? 自己去搜吧 :)

相当的easy~