APT command in Linux with Examples
APT command
APT command solves dependency issues automatically, making installing any package, regardless of the size or number of dependencies in a one line command. In this article, we will study about Understanding APT command, APT-Cache and Their Frequently Used Commands.
To Understand APT command Configuration
Run the following command to look at APT configuration files.
user1@linuxhelp $ sudo cat /etc/apt/sources.list
# deb cdrom:[Ubuntu 15.10 _Wily Werewolf_ - Release amd64 (20151021)]/ wily main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
&hellip .
&hellip .
&hellip
deb http://security.ubuntu.com/ubuntu wily-security universe
deb-src http://security.ubuntu.com/ubuntu wily-security universe
deb http://security.ubuntu.com/ubuntu wily-security multiverse
deb-src http://security.ubuntu.com/ubuntu wily-security multiverse.
Syntax
deb (url) release repository
To get source file repository
Use the following command.
deb-src (url) release repository
There are commonly used repositories in APT systems i.e in Ubuntu as follows,
The repository components are:
Main &ndash Package that supported officially
Restricted &ndash Supported package that is not available under a completely free license.
Universe &ndash Community maintained package, i.e. not officially supported software.
Multiverse &ndash packages that is not free. (no package is open-source)
It’ s a best practice to run an update command before installing some APT packages, because it will update the sources.list files as well as the respective databases.
User1@linuxhelp~$ sudo apt-get update
Here let us try an example of installing word press. First search for word press in the server, using the following command.
User1@linuxhelp~$ sudo apt-cache search wordpress
blogilo - graphical blogging client
drivel - Blogging client for the GNOME desktop
drupal6-mod-views - views modules for Drupal 6
drupal6-thm-arthemia - arthemia theme for Drupal 6
gnome-blog - GNOME application to post to weblog entries
lekhonee-gnome - desktop client for wordpress blogs
libmarkdown-php - PHP library for rendering Markdown data
qtm - Web-log interface program
tomboy-blogposter - Tomboy add-in for posting notes to a blog
wordpress - weblog manager
wordpress-l10n - weblog manager - language files
wordpress-openid - OpenID plugin for WordPress
wordpress-shibboleth - Shibboleth plugin for WordPress
wordpress-xrds-simple - XRDS-Simple plugin for WordPress
zine - Python powered blog engine
APT-Cache
Apt-cache is a command that simply queries the APT cache. Let us try the some example as above. When we use Apt-cache, it leads us to the main package of “ wordpress &ndash weblog manager” , that we want to install it and also tell us the dependencies that are going to be installed along with it.
User1@linuxhelp~$ sudo apt-cache showpkg wordpress
Versions:
Package: wordpress
Versions:
4.3+dfsg-1 (/var/lib/apt/lists/in.archive.ubuntu.com_ubuntu_dists_wily_universe_binary-amd64_Packages)
Description Language:
File: /var/lib/apt/lists/in.archive.ubuntu.com_ubuntu_dists_wily_universe_binary-amd64_Packages
MD5: 3558d680fa97c6a3f32c5c5e9f4a182a
Description Language: en
File: /var/lib/apt/lists/in.archive.ubuntu.com_ubuntu_dists_wily_universe_i18n_Translation-en
MD5: 3558d680fa97c6a3f32c5c5e9f4a182a
Reverse Depends:
dpkg:i386,wordpress 4.1+dfsg-1~
dpkg,wordpress 4.1+dfsg-1~
dpkg:i386,wordpress 4.1+dfsg-1~
wordpress-xrds-simple,wordpress
wordpress-theme-twentythirteen,wordpress
wordpress-theme-twentythirteen,wordpress 3.8+dfsg-1
wordpress-theme-twentythirteen,wordpress 3.8+dfsg-1
wordpress-theme-twentyfourteen,wordpress
wordpress-theme-twentyfifteen,wordpress
&hellip
&hellip
&hellip
So it will display the dependencies of the respective word press package.
To install
Use the following command to install word press.
User1@linuxhelp~$ sudo apt-get installwordpress
To Uninstall package
User1@linuxhelp~$ sudo apt-get remove wordpress
It will remove only the main package from the repo but not the configurations. So to overcome that, use apt-get purge command.
User1@linuxhelp~$ sudo apt-get purge wordpress
To avoid broken dependencies
Run the following command to overcome broken dependencies.
User1@linuxhelp~$ sudo apt-get &ndash f install
Instead of running this command you can go for apt-get autoremove command also.
To free memory space
APT command downloads all of the *.deb files from the repository . So run the following command periodically remove them to free up disk space.
User1@linuxhelp~$ sudoapt-get clean
Syntax: "apt search
wget http://security.ubuntu.com/ubuntu/pool/main/a/apt/apt_1.7.0~alpha2_amd64.
apt-get upgrade