APT (Advanced Packaging Tool) For Debian/Ubuntu/Mint
APT stands for Advanced Packaging Tool (APT) which is replacement for
APT is a powerful command-line tool for installing, downloading, removing, searching and managing as well as querying information about packages as a low-level access to all features of the libapt-pkg library. It’s contains some less used command-line utilities related to package management.
which is used to automatically download, install new software packages, upgrade existing software packages, update the package list index, and to upgrade the entire Debian based systems. Some other package manger utilities which are being used widely in Linux are yum, dnf, apt-get, dpkg, rpm, Zypper, pacman, urpmi, pkg, apt, etc.,
Now, i’m going to play on our Linux Mint 17.3 (Rosa) box to explain and cover mostly used Apt commands with examples.
[General syntax for apt]
8) Update Packages Use the below commands to Upgrade entire system packages or specific package to latest version.
apt-get
, like how DNF
came to picture instead of YUM
.
It’s feature rich command-line tools with included all the futures in
one command (APT) such as apt-cache, apt-search, dpkg, apt-cdrom,
apt-config, apt-key, etc..,. and several other unique features. For
example we can easily install .dpkg
packages through APT
but we can’t do through Apt-Get similar more features are included into APT
command. APT-GET replaced by APT Due to lock of futures missing in apt-get which was not solved.APT
is not a new utility and this was released on July 30, 2004
initially and i don’t know why? since initial this was not recognized
but my guess due to lock of improvement i thing so. Anyhow finally it’s
become one of the best New Package Management tool for Debian Based
Systems. APT will automatically install the necessary dependencies or
delete the packages which depend on the package that is being removed.APT is a powerful command-line tool for installing, downloading, removing, searching and managing as well as querying information about packages as a low-level access to all features of the libapt-pkg library. It’s contains some less used command-line utilities related to package management.
which is used to automatically download, install new software packages, upgrade existing software packages, update the package list index, and to upgrade the entire Debian based systems. Some other package manger utilities which are being used widely in Linux are yum, dnf, apt-get, dpkg, rpm, Zypper, pacman, urpmi, pkg, apt, etc.,
Now, i’m going to play on our Linux Mint 17.3 (Rosa) box to explain and cover mostly used Apt commands with examples.
Note :
On Debian & Ubuntu you will get very less options based on APT but you will get all option on Linux Mint.1) Common syntax/file location for APT
See below for common syntax/file location of APT command.[General syntax for apt]
apt [options] [pkg1] [pkg2] ... [most popular apt commands] [install remove update upgrade full-upgrade purge clean] [apt config file location] /etc/apt/apt.conf [apt Package file location] /etc/apt/sources.list /etc/apt/sources.list.d/ [apt cached file location] /var/cache/apt [apt history file location] /var/log/apt/history.log
2) Install a Package or packages
Use the below command to install any package or packages on your system. In this case i’m going to install apache, MariaDB-server, MariaDB-client. Every time APT ask your confirmation to install the corresponding package. if you want to avoid the confirmation you can do by this adding -y option with APT.[Install a single package] $ sudo apt install apache2 or $ sudo apt -y install apache2
[Install more than one packages] $ sudo apt install MariaDB-server MariaDB-client or $ sudo apt -y install MariaDB-server MariaDB-client
3) Remove a Package or packages
Use the below command to remove/erase any package or packages on your system. In this case I’m going to remove nano & aria2.[Remove a single package] $ sudo apt remove nano Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: nano 0 upgraded, 0 newly installed, 1 to remove and 9 not upgraded. After this operation, 614 kB disk space will be freed. Do you want to continue? [Y/n]
[Remove more than one packages] $ sudo apt remove nano aria2 Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libc-ares2 Use 'apt-get autoremove' to remove it. The following packages will be REMOVED: aria2 nano 0 upgraded, 0 newly installed, 2 to remove and 9 not upgraded. After this operation, 5,089 kB disk space will be freed. Do you want to continue? [Y/n]
Remove a package with all files] $ sudo apt purge nano Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: nano* 0 upgraded, 0 newly installed, 1 to remove and 9 not upgraded. After this operation, 614 kB disk space will be freed. Do you want to continue? [Y/n]
[Alternate command to Remove a package with all files] $ sudo apt remove --purge nano Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: nano* 0 upgraded, 0 newly installed, 1 to remove and 9 not upgraded. After this operation, 614 kB disk space will be freed. Do you want to continue? [Y/n]
[This command removes packages that were installed by other packages and are no longer needed] $ sudo apt autoremove Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
[This command removes an installed package and dependencies] $ sudo apt autoremove nano Reading package lists... Done Building dependency tree Reading state information... Done Package 'nano' is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
4) update a Package or packages
Use the below command to update any package or packages on your system. In this case I’m going to update nano & aria2 to latest version.[update single package] $ sudo apt install --only-upgrade nano Reading package lists... Done Building dependency tree Reading state information... Done nano is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
[update more than one packages] $ sudo apt install --only-upgrade nano aria2
5) Search a package
If you don’t know the exact package name which you want to install, Use the search option it will return the matching string. In this case I’m going to search ftpd.[Search a package] $ sudo apt search ftpd p atftpd - advanced TFTP server p atftpd:i386 - advanced TFTP server p ftpd - File Transfer Protocol (FTP) server p ftpd:i386 - File Transfer Protocol (FTP) server p ftpd-ssl - FTP server with SSL encryption support p ftpd-ssl:i386 - FTP server with SSL encryption support p gadmin-proftpd - GTK+ configuration tool for proftpd p gadmin-proftpd:i386 - GTK+ configuration tool for proftpd p gadmin-proftpd-dbg - GTK+ configuration tool for proftpd debug p gadmin-proftpd-dbg:i386 - GTK+ configuration tool for proftpd debugThe above output clearly shows matching string for ftpd.
6) Check package information
If you want to know the package detailed information before proceeding with the installation. Use the below command, it will give full information about the package like package version, size, repo name, etc..[print package info] $ sudo apt show nano Package: nano State: installed Automatically installed: no Version: 2.2.6-1ubuntu1 Priority: standard Section: editors Maintainer: Ubuntu Developers Architecture: amd64 Uncompressed Size: 614 k Depends: libc6 (>= 2.14), libncursesw5 (>= 5.6+20070908), libtinfo5, dpkg (>= 1.15.4) | install-info Suggests: spell Conflicts: pico, pico, nano Breaks: alpine-pico (<= 2.00+dfsg-5), alpine-pico (<= 2.00+dfsg-5) Replaces: pico, pico Provides: editor Description: small, friendly text editor inspired by Pico GNU nano is an easy-to-use text editor originally designed as a replacement for Pico, the ncurses-based editor from the non-free mailer package Pine (itself now available under the Apache License as Alpine). However, nano also implements many features missing in pico, including: * feature toggles; * interactive search and replace (with regular expression support); * go to line (and column) command; * auto-indentation and color syntax-highlighting; * filename tab-completion and support for multiple buffers; * full internationalization support. Homepage: http://www.nano-editor.org/
7) Update Repository Index
Use the below command to Update/Refresh Repository Index file which was mentioned under /etc/apt/sources.list or /etc/apt/preferences.[Update Repository Index] $ sudo apt update Ign http://packages.linuxmint.com rosa/import Translation-en_IN Ign http://packages.linuxmint.com rosa/import Translation-en Ign http://packages.linuxmint.com rosa/main Translation-en_IN Ign http://packages.linuxmint.com rosa/main Translation-en Ign http://packages.linuxmint.com rosa/upstream Translation-en_IN Ign http://packages.linuxmint.com rosa/upstream Translation-en Fetched 2,349 kB in 14s (162 kB/s) Reading package lists... Done
8) Update Packages Use the below commands to Upgrade entire system packages or specific package to latest version.
[update entire system packages to latest version] $ sudo apt upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following packages will be upgraded: bash-completion firefox firefox-locale-en libexpat1 libexpat1:i386 thunderbird thunderbird-gnome-support thunderbird-locale-en thunderbird-locale-en-us 9 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 79.0 MB of archives. After this operation, 316 kB of additional disk space will be used. Do you want to continue? [Y/n]
[This will perform like above command also upgrade the system to new Product Version] $ sudo apt full-upgrade or $ sudo apt dist-upgrade Reading package lists... Done Building dependency tree Reading state information... Done Calculating upgrade... Done The following packages will be upgraded: bash-completion firefox firefox-locale-en libexpat1 libexpat1:i386 thunderbird thunderbird-gnome-support thunderbird-locale-en thunderbird-locale-en-us 9 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 79.0 MB of archives. After this operation, 316 kB of additional disk space will be used. Do you want to continue? [Y/n]
9) Clean local repository packages
This command removes .deb files for packages that are no longer installed on your system, removing these files from /var/cache/apt/archives may regain a significant amount of diskspace.[Clean local repository packages] $ sudo apt clean [Clean all local repository packages] $ sudo apt autoclean Reading package lists... Done Building dependency tree Reading state information... Done
10) Download a Package Without Installing
If you want to download any packages without installation, you can do it by adding "download" option with apt-get command.[Download a Package Without Installing] $ sudo apt download nano
11) How to Check Broken Dependencies
This command is a diagnostic tool. It does an update of the package lists and checks for broken dependencies.# Check Broken Dependencies # $ sudo apt check Reading package lists... Done Building dependency tree Reading state information... Done
12) Fix Broken Packages
When you are facing "unmet dependencies" while installing package, run the below command to fix Broken Packages.[Fix Broken Packages] $ sudo apt -f install Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
13) List Packages
list is used to display a list of packages, such as installed packages, list of upgradable pacakges, list of packages with version.[List installed Packages] $ sudo apt list --installed a11y-profile-manager-indicator/xenial,now 0.1.10-0ubuntu3 amd64 [installed,automatic] account-plugin-facebook/xenial,xenial,now 0.12+16.04.20160126-0ubuntu1 all [installed,automatic] account-plugin-flickr/xenial,xenial,now 0.12+16.04.20160126-0ubuntu1 all [installed,automatic] account-plugin-google/xenial,xenial,now 0.12+16.04.20160126-0ubuntu1 all [installed,automatic] accountsservice/now 0.6.40-2ubuntu11 amd64 [installed,upgradable to: 0.6.40-2ubuntu11.1] acl/xenial,now 2.2.52-3 amd64 [installed,automatic] acpi-support/xenial,now 0.142 amd64 [installed,automatic]
[List upgradable Packages] $ sudo apt list --upgradable accountsservice/xenial-updates 0.6.40-2ubuntu11.1 amd64 [upgradable from: 0.6.40-2ubuntu11] adium-theme-ubuntu/xenial-updates,xenial-updates 0.3.4-0ubuntu1.1 all [upgradable from: 0.3.4-0ubuntu1] appstream/xenial-updates 0.9.4-1ubuntu1 amd64 [upgradable from: 0.9.4-1] fonts-noto-cjk/xenial-updates,xenial-updates 1:1.004+repack2-1~ubuntu1 all [upgradable from: 1:1.004+repack1-1] language-selector-common/xenial-updates,xenial-updates 0.165.2 all [upgradable from: 0.165.1] language-selector-gnome/xenial-updates,xenial-updates 0.165.2 all [upgradable from: 0.165.1] libaccountsservice0/xenial-updates 0.6.40-2ubuntu11.1 amd64 [upgradable from: 0.6.40-2ubuntu11] libappstream3/xenial-updates 0.9.4-1ubuntu1 amd64 [upgradable from: 0.9.4-1]
[List Packages with versions] $ sudo apt list --all-versions 0ad/xenial 0.0.20-1 amd64 0ad-data/xenial,xenial 0.0.20-1 all 0ad-data-common/xenial,xenial 0.0.20-1 all 0ad-dbg/xenial 0.0.20-1 amd64 0install/xenial 2.10-2 amd64 0install-core/xenial 2.10-2 amd64 0xffff/xenial 0.6.1-3 amd64 2048-qt/xenial 0.1.6-1 amd64 2ping/xenial,xenial 3.2.1-1 all
14) List installed package Location
List files location belongs to particular package.[List installed Packages] $ sudo apt content nano /. /bin /bin/nano /bin/rnano /etc /etc/nanorc /usr /usr/bin /usr/bin/nano /usr/share /usr/share/doc /usr/share/doc-base
15) Check package Dependencies
Check All Dependencies for particular Package.[List installed Packages] $ sudo apt depends nano nano Depends: libc6 Depends: libncursesw5 Depends: libtinfo5 |Depends: dpkg dpkg:i386 Depends: install-info install-info:i386 Suggests: spell Conflicts: Conflicts: Breaks: alpine-pico Breaks: alpine-pico:i386 Replaces: Replaces: Conflicts: nano:i386 [List Recommended Missing Packages] $ sudo apt recommends nano No missing recommended packages were found for nano
16) Check installed package version
Print given package version by issuing below command.[Print installed Package version] $ sudo apt version nano 2.2.6-1ubuntu1
17) install deb package
Install deb package directly from apt command.[Install deb Package] $ sudo apt deb vivaldi-stable_1.0.435.40-1_i386.deb
18) Check Change Log of Package
If you want to know, what are the changes made on the packages before upgrading you can check using below command.[Check Change Log of Package] $ sudo apt changelog curl curl (7.35.0-1ubuntu2.6) trusty-security; urgency=medium * SECURITY UPDATE: NTLM credentials not-checked for proxy connection re-use - debian/patches/CVE-2016-0755.patch: fix ConnectionExists to compare Proxy credentials in lib/url.c. - CVE-2016-0755 -- Marc Deslauriers Tue, 26 Jan 2016 12:10:58 -0500 curl (7.35.0-1ubuntu2.5) trusty-security; urgency=medium
19) Add PPA
To add all the third party's PPA to Linux Mint based systems, use the below command.[Add PPA to system] $ sudo apt add-repository ppa:fossfreedom/rhythmbox
20) Reinstall a Package
Download and (possibly) reinstall a currently installed package.[Reinstall Package] $ sudo apt reinstall nano The following packages will be REINSTALLED: nano 0 packages upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 9 not upgraded. Need to get 0 B/194 kB of archives. After unpacking 0 B will be used. (Reading database ... 177111 files and directories currently installed.) Preparing to unpack .../nano_2.2.6-1ubuntu1_amd64.deb ...
21) List Package contain file
$ apt contains nano nano: /bin/nano nano: /bin/rnano nano: /etc/nanorc nano: /usr/bin/nano nano: /usr/share/doc-base/nano nano: /usr/share/doc-base/nano-faq nano: /usr/share/doc/nano nano: /usr/share/doc/nano/AUTHORS nano: /usr/share/doc/nano/BUGS.gz nano: /usr/share/doc/nano/changelog.Debian.gz
22) How to get help from apt-get
If you want additional options, try below commands.# man page of apt-get # $ man apt # apt-get help, page # $ apt --help add-repository - Add entries to apt sources.list autoclean - Erase old downloaded archive files autoremove - Remove automatically all unused packages build - Build binary or source packages from sources build-dep - Configure build-dependencies for source packages changelog - View a package's changelog check - Verify that there are no broken dependencies clean - Erase downloaded archive files contains - List packages containing a file content - List files contained in a package deb - Install a .deb package depends - Show raw dependency information for a package dist-upgrade - Perform an upgrade, possibly installing and removing packages download - Download the .deb file for a package dselect-upgrade - Follow dselect selections held - List all held packages help - Show help for a command hold - Hold a package install - Install/upgrade packages policy - Show policy settings purge - Remove packages and their configuration files recommends - List missing recommended packages for a particular package rdepends - Show reverse dependency information for a package reinstall - Download and (possibly) reinstall a currently installed package remove - Remove packages search - Search for a package by name and/or expression show - Display detailed information about a package source - Download source archives sources - Edit /etc/apt/sources.list with nano unhold - Unhold a package update - Download lists of new/upgradable packages upgrade - Perform a safe upgrade version - Show the installed version of a package
Comments
Post a Comment