This article will describe apt command tips.
Table of Contents
1 What is apt command
This is a command that puts apt-get and apt-cache into one command. If you are tired of "apt-get search" or "apt-cache install", you can use "apt search" and "apt install". And apt has a progress bar.
Commands from apt-get / apt-cache are as below.
|apt install <pkgname>||Install package.|
|apt remove <pkgname>||Uninstall package.|
|apt autoremove||Uninstall packages installed for dependency.|
|apt search <pkgname>||Search package.|
|apt show <pkgname>||Show package information.|
|apt update||Update repository and get upgradeable packages.|
|apt upgrade||Upgrade packages.|
|apt dist-upgrade||Upgrade packages which will cause replace packages.|
|apt -f install||Fix broken package dependency.|
|apt <command> –just-print||Simulate command which enable checking packages.|
Original commands of apt are as below.
|apt list –upgradeable||Show upgradeable packages.|
|apt list –installed||Show installed packages.|
3 The difference between apt upgrade and apt-get upgrade
apt upgrade might install new packages. apt-get upgrade does not install new packages.
apt dist-upgrade and apt-dist-upgrade might install new packages and remove installed packages.
You should use apt upgrade.
3.1 apt-get upgrade does not upgrade kernel package
There are security update packages.
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-21-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 7 packages can be updated. 7 updates are security updates. Last login: Sat Jul 9 21:56:03 2016 from 192.168.11.4
Security update packages are kernel packages.
$ apt list --upgradable Listing... Done linux-generic/xenial-updates,xenial-security 188.8.131.52.30 amd64 [upgradable from: 184.108.40.206.22] linux-headers-generic/xenial-updates,xenial-security 220.127.116.11.30 amd64 [upgradable from: 18.104.22.168.22] linux-image-generic/xenial-updates,xenial-security 22.214.171.124.30 amd64 [upgradable from: 126.96.36.199.22]
apt-get upgrade does not upgrade these packages because kernel packages are considered to be install packages.
$ sudo apt-get upgrade -y Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following packages have been kept back: linux-generic linux-headers-generic linux-image-generic 0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
apt upgrade will upgrade these packages.
$ sudo apt upgrade -y Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following NEW packages will be installed: linux-headers-4.4.0-28 linux-headers-4.4.0-28-generic linux-image-4.4.0-28-generic linux-image-extra-4.4.0-28-generic The following packages will be upgraded: linux-generic linux-headers-generic linux-image-generic 3 upgraded, 4 newly installed, 0 to remove and 0 not upgraded. Need to get 68.3 MB of archives. After this operation, 295 MB of additional disk space will be used. Get:1 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-image-4.4.0-28-generic amd64 4.4.0-28.47 [18.7 MB]
apt-get upgrade with –with-new-pkgs option will upgrade these packages.
$ sudo apt-get upgrade --with-new-pkgs # equal with sudo apt upgrade.