apt-get

APT Overview

APT (Advanced Package Tool)

two main tools:
1. apt-get
2. apt-cache

Update the package database

$ sudo apt-get update

运行该command后,会有一系列的lines出现。

  • hit: there is no change in package version
  • ign: the package is being ignored.
  • get: There is a new version available. It will download the information not the package itself.

Upgrade installed packages with apt-get

更新所有有更新可用的

sudo apt-get upgrade  

upgrade某package

sudo apt-get upgrade <package name>  

Complete upgrade

sudo apt-get dist-upgrade  

upgrade vs dist-upgrade

upgrade: 不remove packages or install a new package

dist-upgrade: looks for dependences with the newer version of the package being installed and tries to install a new package or remove an existing one.

search packages

apt-cache search <keyword>  

显示package内容

apt-cache showpkg <package_name>  

Install a package without upgrading it

sudo apt-get install <package_name> --no-upgrade  

Install a specific version of an application

sudo apt-get intall <package-name>=<version_name>  

Remove installed package

# removes the binaries of a package
sudo apt-get remove <package_name>

# removes everything
sudo apt-get purge <package_name>  

国内源

debian为例

debian的库有:
1. main
2. security (安全更新库)
3. Backports (Backports - Debian Wiki)
4. Multimedia (多媒体)

Reference

Using apt-get Commands In Linux [Complete Beginners Guide]