Basic Commands of APT-GET and APT-CACHE for Package Management


Apt-get is the command-line utility for dealing with applications and may be considered for the person’s “back-end” to other tools for making use of the APT library.Apt-cache performs a variety of operations on APT’s package.This article explains about -“Basic Commands of APT-GET and APT-CACHE for Package Management”.

Apt-get

To get the more options about apt-get, use the following command as shown below –

$ apt-get -h

The sample output contains the following options as shown below –

update - Retrieve new lists of packages
   upgrade - Perform an upgrade
   install - Install new packages (pkg is libc6 not libc6.deb)
   remove - Remove packages
   purge - Remove packages and config files
   autoremove - Remove automatically all unused packages
   dist-upgrade - Distribution upgrade, see apt-get(8)
   dselect-upgrade - Follow dselect selections
   build-dep - Configure build-dependencies for source packages
   clean - Erase downloaded archive files
   autoclean - Erase old downloaded archive files
   check - Verify that there are no broken dependencies
   source - Download source archives
   download - Download the binary package into the current directory
   changelog - Download and display the changelog for the given package

Installing package

To install the package with apt-get, use the following command as shown below –

$ sudo apt-get install <package name>

Ugrade the software packages

To upgrade the software packages, use the following command –

$ sudo apt-get upgrade

Remove unused packages

To remove automatically all unused packages, use the following command –

$ sudo apt-get autoremove

Erase downloaded archive files

To erase downloaded archive files, use the following command –

$ sudo apt-get clean

Erase old downloaded archives

To erase old downloaded archive files, use the following command –

$ sudo apt-get autoclean

Verify broken Dependencies

To verify that there are no broken dependencies, use the following command –

$ sudo apt-get check

Apt-cache

To get the more options about apt-cache, use the following commands –

$ sudo apt-cache --help

The sample options of apt-cache as shown below –

showsrc - Show source records
   search - Search the package list for a regex pattern
   depends - Show raw dependency information for a package
   rdepends - Show reverse dependency information for a package
   show - Show a readable record for the package
   pkgnames - List the names of all packages in the system
   policy - Show policy settings

Get the dependencies of package

To get the dependencies of package or source records, use the following command –

$sudo apt-cache showsrc <packegename>

Package list of a regex pattern

To get the package list for a regex pattern, use the following command –

$sudo apt-cache search <packegename>

Raw dependency information

To show raw dependency information for a package, use the following command –

$ apt-cache depends <packegename>

Show reverse dependency information

To show reverse dependency information for a package, use the following command –

$ apt-cache rdepends <packegename>

Show a readable record

To show a readable record for the package, use the following command –

$ apt-cache show <packegename>

Show the names of all packages

To show the names of all packages in the system, use the following command –

$ apt-cache pkgnames

In the above article, we have learnt about – Learn Basic Commands of APT-GET and APT-CACHE for Package Management. In our next articles, we will come up with more Linux based tricks and tips. Keep reading.

Updated on: 23-Jan-2020

257 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements