blog posts

Package management in Linux

This post teaches you how to install, remove, update, and search for software packages using the apt-get and apt-cache commands in Debian-based Linux distributions (such as Ubuntu / Debian / Mint, etc.). In this post, we have provided useful instructions that will help you manage packages in Debian / Ubuntu systems.

What is apt-get?

Apt-get software is in fact a very powerful and free command-line program for package management. Moreover, people use this software to work with the APT Library in ubuntu, which stands for Advanced Packaging Tool. Runs new software packages, deletes existing software packages, updates existing software packages, or even upgrades the entire operating system. Users use the apt-cache command to search the cache of the apt software package. Simply put, users use this tool to search for the software packages, package information collection, as well as search for existing packages that are ready to install for the Ubuntu or Debian operating system.

5 useful basic commands from apt-cache

How to list all available packages

Run the following command to list all available packages:

PHP code:
$ apt-cache pkgnames

esseract-ocr-epo
pipenightdreams
mumudvb
tbb-examples
libsvm-java
libmrpt-hmtslam0.9
libboost-timer1.50-dev
kcm-touchpad
g++-4.5-multilib

How to find the package name and software description

To find the package name along with the description before installing it, we must use the search option. Using search with apt-cache The list of match packages will be displayed with a brief description. For example, to find the description of the vsftpd package, run the following command:

PHP code:

$ apt-cache search vsftpd

vsftpd – lightweight, efficient FTP server written for security

ccze – A robust, modular log coloriser

ftpd – File Transfer Protocol (FTP) server

yasat – simple stupid audit tool

Moreover, Run the following command to find and list all packages starting with vsftpd:

PHP code:

$ apt-cache pkgnames vsftpd

vsttpd

How to check the package information

In the beginning, If we want to check the package information along with short descriptions (version number, summary, size, installation size, group, etc.) we must execute the following command:
PHP code:

$ apt-cache show netcat

Package: netcat
Priority: optional
Section: universe/net
Installed-Size: 30
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Ruben Molina <rmolina@udea.edu.co>
Architecture: all
Version: 1.10-40
Depends: netcat-traditional (>= 1.10-39)
Filename: pool/universe/n/netcat/netcat_1.10-40_all.deb
Size: 3340
MD5sum: 37c303f02b260481fa4fc9fb8b2c1004
SHA1: 0371a3950d6967480985aa014fbb6fb898bcea3a
SHA256: eeecb4c93f03f455d2c3f57b0a1e83b54dbeced0918ae563784e86a37bcc16c9
Description-en: TCP/IP swiss army knife — transitional package
This is a “dummy” package that depends on lenny’s default version of
 netcat, to ease upgrades. It may be safely removed.
Description-md5: 1353f8c1d079348417c2180319bdde09
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu 

How to check the dependencies of a particular package

The showpkg option for the apt-cache command checks the prerequisite packages for the desired software. Also whether these prerequisite packages are installed on the system or not. To do this, run the following command:

PHP code:

$ apt-cache showpkg vsftpd

Package: vsftpd
Versions:
2.3.5-3ubuntu1 (/var/lib/apt/lists/in.archive.ubuntu.com_ubuntu_dists_quantal_main_binary-i386_Packages)
 Description Language:
                 File: /var/lib/apt/lists/in.archive.ubuntu.com_ubuntu_dists_quantal_main_binary-i386_Packages
                  MD5: 81386f72ac91a5ea48f8db0b023f3f9b
 Description Language: en
                 File: /var/lib/apt/lists/in.archive.ubuntu.com_ubuntu_dists_quantal_main_i18n_Translation-en
                  MD5: 81386f72ac91a5ea48f8db0b023f3f9b

Reverse Depends:
  ubumirror,vsftpd
  harden-servers,vsftpd
Dependencies:
2.3.5-3ubuntu1  – debconf (18 0.5) debconf-2.0 (0 (null)) upstart-job (0 (null)) libc6  (2 2.15) libcap2 (2 2.10) libpam0g (2 0.99.7.1) libssl1.0.0 (2 1.0.0)  libwrap0 (2 7.6-4~) adduser (0 (null)) libpam-modules (0 (null)) netbase  (0 (null)) logrotate (0 (null)) ftp-server (0 (null)) ftp-server (0  (null))
Provides:
2.3.5-3ubuntu1 – ftp-server
Reverse Provides: 

How to check the cache

First, the stats option will display all cache statistics. For example, the following command will display the total number of package names in the cache:

PHP code:

$ apt-cache stats

Total package names: 51868 (1,037 k)
Total package structures: 51868 (2,490 k)
  Normal packages: 39505
  Pure virtual packages: 602
  Single virtual packages: 3819
  Mixed virtual packages: 1052
  Missing: 6890
Total distinct versions: 43015 (2,753 k)
Total distinct descriptions: 81048 (1,945 k)
Total dependencies: 252299 (7,064 k)
Total ver/file relations: 45567 (729 k)
Total Desc/File relations: 81048 (1,297 k)
Total Provides mappings: 8228 (165 k)
Total globbed strings: 286 (3,518 )
Total dependency version space: 1,145 k
Total slack space: 62.6 k
Total space accounted for: 13.3 M