Useful Illustrations of Ubuntu apt-get and apt-cache Commands

Using Ubuntu Linux might sound too scary and difficult for most of you, but once you become aware of the simplest and most common commands here, you will understand that there’s nothing either complex, or frightful. On the contrary, many beginners, eventually, became real experts in Linux OS. However, to achieve the same goal, it is important for you to know the main commands to operate and use the Linux Ubuntu in a most beneficial way. Today, we are about to discuss the Apt-get & apt-cache command line, which is a package management utility for the Linux Ubuntu system. Note that the GUI version for the apt-get command is actually the Synaptic Package Manager. And our tutorial will show you 15 different illustrations that will teach you how to use the two commands – apt-get and apt-cache.

List all installed packages

howopensource@esprimo:~$ dpkg-query -l | more
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                 Version                        Architecture Description
+++-====================================-==============================-============-==============================================================
ii  acl                                  2.2.51-8                       i386         Access control list utilities
ii  acpi                                 1.6-1                          i386         displays information on ACPI devices
ii  adduser                              3.113+nmu3                     all          add and remove users and groups
ii  alsa-base                            1.0.25+3~deb7u1                all          ALSA driver configuration files
ii  alsa-utils                           1.0.25-4                       i386         Utilities for configuring and using ALSA
ii  apache2                              2.2.22-13+deb7u4               i386         Apache HTTP Server metapackage
..................................................

The full list of the packages that is currently available

howopensource@esprimo:~$ apt-cache pkgnames | more
account-plugin-yahoojp
ceph-fuse
dvd+rw-tools
e3
gnome-commander-data
..................................................

list all available packages with apt-cache

Packages for searches with particular keywords to be used
With this useful command you can easily find the package, when you do not know its name. All you need to do is to input the particular keyword, when the apt-get command will show you the list of all the packages that correspond to this particular keyword.

howopensource@esprimo:~$ apt-cache search "ball-and-paddle game"
lbreakout2 - ball-and-paddle game with nice graphics
lbreakout2-data - ball-and-paddle game with nice graphics (DATA FILES)
howopensource@esprimo:~$ 

howopensource@esprimo:~$ apt-cache search "web editor"
fckeditor - rich text format javascript web editor
howopensource@esprimo:~$ 

howopensource@esprimo:~$ apt-cache search "email client"
alpine - Text-based email client, friendly for novices but powerful
claws-mail - Fast, lightweight and user-friendly GTK+2 based email client
geary - lightweight email client designed for the GNOME desktop
kmail - full featured graphical email client
kmail-mobile - email client for mobile environments
howopensource@esprimo:~$ 

Ubuntu apt-cache search packages with keyword

In case you have apt-file installed on your Ubuntu Linux, you might also search for the package by using the following configuration files.

howopensource@esprimo:~$ apt-file search apache2
apache2: /etc/apache2/apache2.conf
apache2: /etc/apache2/conf-available/charset.conf
apache2: /etc/apache2/conf-available/localized-error-pages.conf
apache2: /etc/apache2/envvars
apache2: /etc/apache2/magic
..................................................

apt-file search for installed file

How to put on display the main information for each specific package?

howopensource@esprimo:~$ apt-cache show lbreakout2
Package: lbreakout2
Priority: optional
Section: universe/games
Description-en: ball-and-paddle game with nice graphics
 lbreakout2 is a game similar to the classics breakout and xboing, featuring
 a number of added graphical enhancements and effects.  You control a paddle
 at the bottom of the playing-field, and must destroy bricks at the top
 by bouncing balls against them.

Ubuntu show package info

How to show the dependency of each package?

howopensource@esprimo:~$ apt-cache depends lbreakout2
lbreakout2
  Depends: libc6
  Depends: libpng12-0
..................................................

How to show the statistic for Cache with the apt-cache command?

howopensource@esprimo:~$ apt-cache stats
Total package names: 60913 (1,218 k)
Total package structures: 102876 (5,761 k)
howopensource@esprimo:~$ 

Ubuntu show apt-cache statistics

How to update the package storage with the apt-get command update?
When you use the apt-get update command, you might synchronize the package index files once again by adjusting them to the source they belong to. You can retrieve the package index from a file, which is situated in the /etc/apt/sources.list.

howopensource@esprimo:~$ sudo apt-get update
Hit http://extras.ubuntu.com utopic Release.gpg
Hit http://extras.ubuntu.com utopic Release                                
Hit http://extras.ubuntu.com utopic/main Sources                  
Hit http://security.ubuntu.com utopic-security Release.gpg        

How to install a package with the apt-get command?
This illustration shows an installation of a package with a name lbreakout2.

howopensource@esprimo:~$ sudo apt-get install lbreakout2

How to perform the upgrading of all the available packages?

howopensource@esprimo:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
howopensource@esprimo:~$ 

Ubuntu apt-get upgrade

How to perform the upgrading of a specific package?

howopensource@esprimo:~$ sudo apt-get install lbreakout2 --only-upgrade
..................................................

How to remove a particular package with the apt-get command?
This illustration shows the removal or full deletion of the package lbreakout2, but in case you aim to eliminate all the configuration files of this package, you should apply the purge feature by using the apt-get command. See it now. Also, it is possible to apply a combo of several commands, which we showed above.

howopensource@esprimo:~$ sudo apt-get remove lbreakout2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  lbreakout2
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 785 kB disk space will be freed.
Do you want to continue? [Y/n] 

howopensource@esprimo:~$ sudo apt-get purge lbreakout2
..................................................

How to download a particular package and store it in Current Working Directory?
The example shows the command that will download a package, which is named lbreakout2 directly to your present working directory.

howopensource@esprimo:~$ sudo apt-get download lbreakout2
Get:1 http://us.archive.ubuntu.com/ubuntu/ utopic/universe lbreakout2 amd64 2.6.4-3 [242 kB]
Fetched 242 kB in 0s (658 kB/s)
howopensource@esprimo:~$ 

How to empty the space in the disk, which is full of files from retrieved packages?
This illustration shows the emptying of the disk space with the apt-get command during the retrieving package process. Bear in mind that you can also get the benefit of the feature autoclean, too.

howopensource@esprimo:~$ sudo apt-get clean
howopensource@esprimo:~$ 

howopensource@esprimo:~$ sudo apt-get autoclean
Reading package lists... Done
Building dependency tree       
Reading state information... Done
howopensource@esprimo:~$ 

Ubuntu apt-get autoclean

How to remove the packages with the autoremove parameter?
When we apply the parameter autoremove in a combo with apt-get command, we can eliminate all the packages, which were previously installed for the dependency of other packages, but they are not necessary or put into usage any more.

howopensource@esprimo:~$ sudo apt-get autoremove lbreakout2

How to show the changelog in a package?
This illustration shows the command for downloading the changelog for the lbreakout2 package and it also shows a sensible-pager on your Linux-based desktop.

howopensource@esprimo:~$ sudo apt-get changelog lbreakout2
Get:1 Changelog for lbreakout2 (http://changelogs.ubuntu.com/changelogs/pool/universe/l/lbreakout2/lbreakout2_2.6.4-3/changelog) [13.9 kB]
Fetched 13.9 kB in 0s (56.6 kB/s)   
howopensource@esprimo:~$ 

How to see the dependencies, which were broken, with the feature check?

howopensource@esprimo:~$ sudo apt-get check
Reading package lists... Done
Building dependency tree       
Reading state information... Done
howopensource@esprimo:~$ 

And finally if you are wondering what is lbreakout2 that was used in most of examples. It is an classic ball and paddle game with nice graphics and sound effects. It is fun and nice to play for a few minutes daily when you need rest and need to clear your mind.

Ubuntu game lbreakout2

Related Posts Plugin for WordPress, Blogger...