apt-get is the first front end — command-line based — which was developed within the project. apt is a second command-line based front end provided by APT which overcomes some design mistakes of apt-get.
apt has been improved for interactive use and to actually do what most users expect. The APT developers reserve the right to change the public interface of this tool to further improve it. On the opposite, the public interface of apt-get is well defined and will not change in any backwards incompatible way. It is thus the tool that you want to use when you need to script package installation requests.
synaptic, aptitude (which includes both a text mode interface and a graphical one — even if not complete yet), wajig, etc. The most recommended interface, apt, is the one that we will use in the examples given in this section. Note, however, that apt-get and aptitude have a very similar command line syntax. When there are major differences between these three commands, these will be detailed.
apt update. Depending on the speed of your connection and configuration, the operation can take a while, since it involves downloading a certain number of (usually compressed) files (Packages, Sources, Translation-language-code), which have gradually become bigger and bigger as Debian has developed (at least 10 MB of data for the main section). Of course, installing from a CD-ROM/DVD set does not require any downloading — in this case, the operation is very fast.
apt install package and apt remove package. In both cases, APT will automatically install the necessary dependencies or delete the packages which depend on the package that is being removed. The apt purge package command involves a complete uninstallation by deleting the configuration files as well.
sources.list mentions several distributions, it is possible to give the version of the package to install. A specific version number can be requested with apt install package=version, but indicating its distribution of origin (Stable, Testing or Unstable) — with apt install package/distribution — is usually preferred. With this command, it is possible to go back to an older version of a package (if, for instance, you know that it works well), provided that it is still available in one of the sources referenced by the sources.list file. Otherwise the snapshot.debian.org archive can come to the rescue (see sidebar INDO ALÉM versões de pacotes antigas: snapshot.debian.org).
Exemplo 6.4. Installation of the Unstable version of spamassassin
#apt install spamassassin/unstable
.deb file without any associated package repository, it is still possible to use APT to install it together with its dependencies (provided that the dependencies are available in the configured repositories) with a simple command: apt install ./path-to-the-package.deb. The leading ./ is important to make it clear that we are referring to a filename and not to the name of a package available in one of the repositories.
apt upgrade, apt-get upgrade ou aptitude safe-upgrade (claro que depois de um apt update). Este comando busca por pacotes instalados que possam ser atualizados sem remover nenhum pacote. Em outras palavras, o objetivo é garantir uma atualização com o mínimo de transtorno possível. O apt-get é um pouco mais pesado que aptitude ou o apt por que ele vai se recusar a instalar pacotes que não estavam instalados antes.
apt vai geralmente selecionar o número de versão mais recente (exceto para pacotes de Experimental e stable-backports, que são normalmente ignorados independente do número da versão). Se você especificar a versão Testing ou a Unstable em seu arquivo sources.list, um apt upgrade vai trocar a maioria do seu sistema Stable para Testing ou Unstable, que pode não ser o que você pretende.
apt to use a specific distribution when searching for upgraded packages, you need to use the -t or --target-release option, followed by the name of the distribution you want (for example, apt -t stable upgrade). To avoid specifying this option every time you use apt, you can add APT::Default-Release "stable"; in the file /etc/apt/apt.conf.d/local.
apt full-upgrade. Com esta instrução, o apt vai completar a atualização mesmo se ele tiver que remover alguns pacotes obsoletos ou instalar novas dependências. Este também é o comando usado pelos usuários que trabalham diariamente com a versão Debian Unstable e seguem sua evolução dia após dia. É tão simples que dispensa explicações: a reputação do APT é baseada nesta fantástica funcionalidade.
apt e aptitude, o apt-get não conhece o comando full-upgrade. Em seu lugar, você deve usar apt-get dist-upgrade (”atualização de distribuição”), o histórico e bem conhecido comando que o apt e aptitude também aceitam para conveniência dos usuários que ficaram acostumados com ele.
/var/log/apt/history.log and /var/log/apt/term.log, whereas dpkg keeps its log in a file called /var/log/dpkg.log.
/etc/apt/apt.conf.d/ directory or /etc/apt/apt.conf itself. Remember, for instance, that it is possible for APT to tell dpkg to ignore file conflict errors by specifying DPkg::options { "--force-overwrite"; }.
Acquire::http::proxy "http://seu-proxy:3128". Para um proxy FTP, escreva Acquire::ftp::proxy "ftp://seu-proxy". Para descobrir mais opções de configuração, leia a página de manual do apt.conf(5) com o comando man apt.conf (para detalhes sobre páginas de manual, veja Seção 7.1.1, “Páginas de Manual”).
-t ou a diretiva de configuração APT::Default-Release).
/etc/apt/preferences.d/ or the /etc/apt/preferences file with the names of the affected packages, their version, their origin and their new priority.
/etc/apt/preferences and /etc/apt/preferences.d/, it first takes into account the most specific entries (often those specifying the concerned package), then the more generic ones (including, for example, all the packages of a distribution). If several generic entries exist, the first match is used. The available selection criteria include the package's name and the source providing it. Every package source is identified by the information contained in a Release file that APT downloads together with the Packages files. It specifies the origin (usually “Debian” for the packages of official mirrors, but it can also be a person's or an organization's name for third-party repositories). It also gives the name of the distribution (usually Stable, Testing, Unstable or Experimental for the standard distributions provided by Debian) together with its version (for example, 10 for Debian Buster). Let's have a look at its syntax through some realistic case studies of this mechanism.
/etc/apt/preferences :
Package: * Pin: release a=stable Pin-Priority: 900 Package: * Pin: release o=Debian Pin-Priority: -10
a=stable define o nome da distribuição selecionada. o=Debian limita o escopo para pacotes cuja origem seja "Debian".
Package: perl Pin: version 5.24* Pin-Priority: 1001
apt-cache policy to display the default priority associated with each package source, or apt-cache policy package to display the default priority for each available version and source of a package as explained in DICA apt-cache policy.
/etc/apt/preferences and /etc/apt/preferences.d/ is available in the manual page apt_preferences(5), which you can display with man apt_preferences.
apt uma ferramenta assim tão maravilhosa, é tentador pegar pacotes de outras ditribuicões. Por exemplo, depois de instalar um sistema Stable, você pode querer tentar um pacote de software disponível na Testing ou Unstable sem divergir muito do estado inicial do sistema.
apt gerencia tal coexistência muito bem e limita os riscos de forma bastante efetiva. A melhor maneira de proceder é listando todas as distribuições usadas em /etc/apt/sources.list (algumas pessoas sempre botam as três distribuições, mas lembre-se que Unstable é reservada para usuários experientes) e definindo a sua distribuição de referência com o parâmetro APT::Default-Release (Veja Seção 6.2.3, “Atualização do sistema”).
sources.list. Neste caso, você pode usar apt- install pacote/testing para instalar um pacote da Testing. Se a instalação falha devido a algumas dependências não-satisfeitas, deixe ela resolver estas dependências na Testing adicionando o parâmetro -t testing. O mesmo obviamente se aplica à Unstable.
upgrade e full-upgrade) são feitas no Stable exceto para pacotes já atualizados para uma outra distribuição: estes vão seguir as atualizações disponíveis em outras distribuições. Nós iremos explicar este comportamento com a ajuda de prioridades padrão configuradas pelo APT abaixo. Não hesite em usar apt-cache policy (veja a barra lateral DICA apt-cache policy) para verificar as prioridades dadas.
/etc/apt/preferences não foi usado para forçar prioridades maiores que 1000 para alguns pacotes).
/etc/apt/preferences to this effect:
Package: * Pin: release a=unstable Pin-Priority: 490
apt is the tracking of packages installed only through dependencies. These packages are called “automatic”, and often include libraries.
apt-get autoremove or apt autoremove will get rid of those packages. aptitude does not have this command because it removes them automatically as soon as they are identified. In all cases, the tools display a clear message listing the affected packages.
apt-mark auto pacote marcará o pacote dado como automático enquanto apt-mark manual pacote faz o oposto. aptitude markauto e aptitude unmarkauto trabalham da mesma forma, embora eles ofereçam mais recursos para a marcação de muitos pacotes de uma vez (veja Seção 6.5.1, “aptitude”). A interface interativa baseada em console do aptitude também torna mais fácil para analisar a "opção automático" em muitos pacotes.
aptitude why pacote (apt e apt-get não tem recurso semelhante):
$aptitude why python-debiani aptitude Suggests apt-xapian-index p apt-xapian-index Depends python-debian (>= 0.1.14)