apt-get

apt-get (Advanced Package Tool) 这个命令,在 Debian/Ubuntu 中用的实在太多了,这里把常用到的几个指令记录一下。更详细的资料可以参看 https://wiki.debian.org/apt-get

更新系统

$ sudo apt-get update

安装软件

$ sudo apt-get install {software name}

卸载软件

$ sudo apt-get remove {software name} # 只删除 package

or

$ sudo apt-get purge {software name} # 删除 package and config

自动删除无用的软件包

$ sudo apt-get autoremove

删除 cache 中多余的软件包

$ sudo apt-get autoclean
$ sudo apt-get clean

查看帮助

$ apt-get --help

apt-get 帮助内容参考

iridium@debianiridium:~$ sudo apt-get --help
[sudo] password for iridium:
apt 0.9.7.9 for amd64 compiled on Oct  8 2014 10:25:29
Usage: apt-get [options] command
       apt-get [options] install|remove pkg1 [pkg2 ...]
       apt-get [options] source pkg1 [pkg2 ...]
apt-get is a simple command line interface for downloading and
installing packages. The most frequently used commands are update
and install.
Commands:
   update - Retrieve new lists of packages
   upgrade - Perform an upgrade
   install - Install new packages (pkg is libc6 not libc6.deb)
   remove - Remove packages
   autoremove - Remove automatically all unused packages
   purge - Remove packages and config files
   source - Download source archives
   build-dep - Configure build-dependencies for source packages
   dist-upgrade - Distribution upgrade, see apt-get(8)
   dselect-upgrade - Follow dselect selections
   clean - Erase downloaded archive files
   autoclean - Erase old downloaded archive files
   check - Verify that there are no broken dependencies
   changelog - Download and display the changelog for the given package
   download - Download the binary package into the current directory
Options:
  -h  This help text.
  -q  Loggable output - no progress indicator
  -qq No output except for errors
  -d  Download only - do NOT install or unpack archives
  -s  No-act. Perform ordering simulation
  -y  Assume Yes to all queries and do not prompt
  -f  Attempt to correct a system with broken dependencies in place
  -m  Attempt to continue if archives are unlocatable
  -u  Show a list of upgraded packages as well
  -b  Build the source package after fetching it
  -V  Show verbose version numbers
  -c=? Read this configuration file
  -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp
See the apt-get(8), sources.list(5) and apt.conf(5) manual
pages for more information and options.
                       This APT has Super Cow Powers.

再举两个使用示例

$ sudo apt-get -f install {software name}
$ sudo apt-get -qq -y update