May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Installing software via Apt

Installing software via Apt

I regularly sit in the #ubuntu channel on the Freenode network helping folks with Ubuntu issues. One of the things I see people often doing is attempting to install software from source before researching easier installation methods. This tutorial is focuses on using the command line to perform a set of tasks. I have written a CLI cheatsheet for those of you who feel the need to brush up on your CLI skills.

The proper steps for software installation on Ubuntu, in my opinion, are as follows:

Step 1

Search the Ubuntu software repositories (known as repos). The Ubuntu repos are huge and there's a good chance that the app you're looking for is already packaged for use in Ubuntu. It's important to note here that it's best to install software from the repos which are meant for your version of Ubuntu. Mixing release packages (using Jaunty repos in Karmic) or distros (using debian repos in Ubuntu) can cause problems on your system, so stick with the proper repos. If you're unsure as to which version of Ubuntu you are using, run lsb_release -a in a terminal.

You can search the Ubuntu repos with the following commands (package "foo" is used here as an example):
apt-cache search foo - Find packages that include "foo" in the package filename or description
apt-cache search -n foo - Find packages that include "foo" in the package filename

Example 1: You are looking for an irc client but you don't know of any apps which can perform the required task, you would type the following:

apt-cache search irc | grep client

This command tells the system to search the repos for all packages which have "irc" in the description or package filename and filter that search for packages which also have "client" in the description or package filename. Piping the apt-cache command to grep narrows the search down more thanthat which would have resulted in apt-cache search irc.

Example 2: You are looking for the Xchat IRC client, you would type the following:

apt-cache search -n xchat

This command tells the system to search the repos for all packages filenames that contain "xchat".

Once you think you have found the proper package, you can do a bit of investigation with these commands:

apt-cache show xchat - Show information about package xchat
apt-cache depends xchat - Show the dependencies of package xchat
dpkg -L package xchat - List all files in package xchat

Once you have found the proper package, you can install it with the command:

sudo apt-get install xchat

Installing software from the repos has many benefits. The three biggest benefits are that a) the software is easy to install and remove, b) the system will resolve dependencies for you and c) the system will keep the software up-to-date for you.

Step 2
If you're unable to find your desired software after searching the repos, you can try to find a PPA (Personal Package Archive) from which to install the desired software. Personal Package Archives are a type of software repository which are provided by other users to distribute pre-packaged software for Ubuntu. You can search for a PPA here. Most PPA's will include instructions on how to add that PPA to your Ubuntu sources, update your sources and install the desired packages.

Installing software from a PPA has the same benefits as installing software from the official Ubuntu repos.

Step 3
If you're unable to find your desired software after using the above methods, you can try and find a .deb package that was built specifically for Ubuntu. Keep in mind that other distros also uses .deb packages but dependency and other issues come into play when attempting to use a .deb package which wasn't built specifically for Ubuntu. It's also a bad idea to convert a .rpm package into a .deb package and install the software that way. Some folks will tell you that using a Debian .deb package or converting a .rpm package are acceptable methods of installing software in Ubuntu, but these methods are neither recommended nor supported.

There many ways to find a .deb package which is compatible with the Ubuntu system. One way is to use websites such as GetDeb or Gnome Files to search for your desired software. Another way is to use a Linux-specific search engine such as Google Linux to aid your search.

One of the drawbacks to installing from a .deb package is that you may be required resolve dependencies yourself. This can be a rather large job because some dependencies may have dependencies of their own - this is known as "dependency hell" and is a place no user wants to be. Another drawback is that the system will not keep the software up-to-date for you, as it will in installing from the repos, so you're left to update the software manually.

Step 4
The chances of having to compile software from sources are slim these days thanks to the Ubuntu repos, PPA's and the good folks who package .deb files. However, if you've come this far and are still unable to install the desired software, you can attempt to compile and install the software from source. I have been using Linux since 2001 and Ubuntu since 2005 and I don't bother compiling software anymore. Call me lazy if you wish, but if I end up at this step and still don't have the desired software installed, I simply look for another app to do the job - one that is either in the repos or can be installed via a PPA or .deb package. If you have arrived at this step and still wish to continue, my advice is to unpack the sources and read any included instructions, these files are often included as README or INSTALL files. The good news is that you can launch your favorite IRC client and visit the #ubuntu channel on the Freenode network where there are users just like you who spend their time helping folks solve problems.

Using a computer should be fun and easy, so it's best to begin with the least stressful steps to get the job done.

Posted by Ian MacGregor
Tags: Software, Tutorial, Ubuntu  


tracyanne said...
Ian this would be even better if you were a little more in depth, and you provided information about the GUI tools for searching the repositories.

Also what happens if the person doesn't know the names of the application they want, only it's type?

Both of these are issues that I come across regularly.
Mr. Maddog said...
It's not even worth compiling tarballs anymore. It made sense in the old days when it was just CLI programs, but now there's so many dependencies you have to have already installed. Not just the library packages but the 'source code' for them as well. It's way easier to use Software Center, Synatic or even apt-get. Maybe some people think they're 'leet using only UNIX commands...
Ian MacGregor said...
Mr. Maddog, I totally agree.
Nox said...
How safe is it to use PPA @ ?
Ian MacGregor said...
tracyanne, Thank you for the reply, I'll add some extra commands to this tutorial. However, the GUI vs CLI debate boils down to the tool being used and personal preference. I can understand people using a GUI web browser over a CLI web browser because they get a better web experience. But, searching for and installing an app just doesn't justify the extra overhead and potential bugs that accompany a GUI tool in my opinion. I can find an app in the terminal faster than the time it takes for synaptic to authenticate, launch be ready to use. What happens if xorg breaks? What if the system is frozen and the only thing it will allow you to do is ctrl+alt+f1? What if the system you're using is a server? What good is a GUI going to be in these cases? I feel that users should learn their way around the command line now so they aren't stuck when the time comes for them to need these skills.
Ian MacGregor said...
Nox, I've not heard anything negative about them and I've been sitting in the main Ubuntu help channel for years. These PPA's are recommended by Ubuntu developers so I am assuming they are safe to use.

Top Visited
Past week
Past month


Old News ;-)

[Dec 05, 2018] How To Find The Package That Provides A File (Installed Or Not) On Ubuntu, Debian Or Linux Mint - Linux Uprising Blog

Nov 30, 2018 |

There are multiple ways of finding out to which package a particular file belongs to, on Ubuntu, Debian or Linux Mint. This article presents two ways of achieving this, both from the command line.

From the same series:

1. Using apt-file to find the package that provides a file (for repository packages, either installed or not installed)
apt-file indexes the contents of all packages available in your repositories, and allows you to search for files in all these packages.

That means you can use apt-file to search for files inside DEB packages that are installed on your system, as well as packages that are not installed on your Debian (and Debian-based Linux distributions, like Ubuntu) machine, but are available to install from the repositories. This is useful in case you want to find what package contains a file that you need to compile some program, etc.

apt-file cannot find the package that provides a file in case you downloaded a DEB package and installed it, without using a repository. The package needs to be available in the repositories for apt-file to be able to find it.

apt-file may not be installed on your system. To install it in Debian, Ubuntu, Linux Mint and other Debian-based or Ubuntu-based Linux distributions, use this command:

sudo apt install apt-file

This tool find the files belonging to a package by using a database, which needs to be updated in order to be able to use it. To update the apt-file database, use:
sudo apt-file update

Now you can use apt-file to find the DEB package that provides a file, be it a package you've installed from the repositories, or a package available in the repositories, but not installed on your Debian / Ubuntu / Linux Mint system. To do this, run:
apt-file search filename
Replacing filename with the name of the file you want to find.

This command will list all occurrences of filename found in various packages. If you know the exact file path and filename, you can get the search results to only list the package that includes that exact file, like this:

apt-file search /path/to/filename
For example, running only apt-file search cairo.h will list a large list search results:
$ apt-file search cairo.h
fltk1.3-doc: /usr/share/doc/fltk1.3-doc/HTML/group__group__cairo.html
ggobi: /usr/include/ggobi/ggobi-renderer-cairo.h
glabels-dev: /usr/include/libglbarcode-3.0/libglbarcode/lgl-barcode-render-to-cairo.h
glabels-dev: /usr/share/gtk-doc/html/libglbarcode-3.0/libglbarcode-3.0-lgl-barcode-render-to-cairo.html
gstreamer1.0-plugins-good-doc: /usr/share/gtk-doc/html/gst-plugins-good-plugins-1.0/gst-plugins-good-plugins-plugin-cairo.html
guile-cairo-dev: /usr/include/guile-cairo/guile-cairo.h
guitarix-doc: /usr/share/doc/guitarix-doc/namespacegx__cairo.html
ipe: /usr/share/ipe/7.2.7/doc/group__cairo.html
libcairo-ocaml-dev: /usr/share/doc/libcairo-ocaml-dev/html/Pango_cairo.html
libcairo-ocaml-dev: /usr/share/doc/libcairo-ocaml-dev/html/type_Pango_cairo.html
libcairo2-dev: /usr/include/cairo/cairo.h

However, if you know the file path, e.g. you want to find out to which package the file /usr/include/cairo/cairo.h belongs to, run:
apt-file search /usr/include/cairo/cairo.h

This only lists the package that contains this file:
$ apt-file search /usr/include/cairo/cairo.h
libcairo2-dev: /usr/include/cairo/cairo.h

In this example, the package that includes the file I searched for ( /usr/include/cairo/cairo.h ) is libcairo2-dev .

apt-file may also be used to list all the files included in a package ( apt-file list packagename ), perform regex search, and more. Consult its man page ( man apt-file ) and help for more information ( apt-file --help ).

2. Using dpkg to find the package that provides a file (only for installed DEB packages - from any source)
dpkg can also be used to find out to which package a file belongs to. It can be faster to use than apt-file, because you don't need to install anything, and there's no database to update.

However, dpkg can only search for files belonging to installed packages, so if you're searching for a file in a package that's not installed on your system, use apt-file. On the other hand, dpkg can be used to find files belonging to packages that were installed without using a repository, a feature that's not available for apt-file.

To use dpkg to find the installed DEB package that provides a file, run it with the -S (or --search ) flag, followed by the filename (or pattern) you want to see to which package it belongs, like this:

dpkg -S filename

For example, to find out to which package the cairo.h file belongs to, use dpkg -S cairo.h :
$ dpkg -S cairo.h
libgtk2.0-dev:amd64: /usr/include/gtk-2.0/gdk/gdkcairo.h
libcairo2-dev:amd64: /usr/include/cairo/cairo.h
libpango1.0-dev: /usr/include/pango-1.0/pango/pangocairo.h
libgtk-3-dev:amd64: /usr/include/gtk-3.0/gdk/gdkcairo.h

Just like for apt-file, this may show multiple packages that have files containing the filename you're looking for. You can enter the full path of the file to get only the package that contains that specific file. Example:
$ dpkg -S /usr/include/cairo/cairo.h
libcairo2-dev:amd64: /usr/include/cairo/cairo.h

In this example, the Debian package that includes the file I searched for ( /usr/include/cairo/cairo.h ) is libcairo2-dev .

Other notable ways of finding the package a file belongs to is using the online search provided by Ubuntu and Debian:

For both, you'll also find options to find the packages that contain files named exactly like your input keyword, packages ending with the keyword, or packages that contains files whose names contain the keyword.

The Linux Mint package search website doesn't include an option to search for files inside packages, but you can use the Ubuntu or Debian online package search for packages that Linux Mint imports from Debian / Ubuntu.

[Jun 28, 2017] AptGet-Howto - Community Help Wiki

Notable quotes:
"... /etc/apt/sources.list ..."
"... /etc/apt/preferences ..."
"... /etc/apt/preferences ..."
"... /var/cache/apt/archives ..."
"... /var/cache/apt/archives ..."
"... not ..."
"... /etc/apt/apt.conf ..."
Jun 28, 2017 |

The apt tool on Ubuntu 14.04 and above makes this very easy to list installed packages apt list --installed

All these commands except the search commands must be run as root or with superuser privileges, see sudo for more information.

Installation commands auto-apt

Maintenance commands

Removal commands

Search commands

For more information on apt-get, apt-cache and dpkg consult their manual pages by using the man command. These manuals will provide a wider scope of information in addition to all of the options that you can use with each program.

Typical usage example

I want to feel the wind in my hair, I want the adrenaline of speed. So let's install a racing game. But what racing games are available?

apt-cache search racing game

It gives me a lot of answers. I see a game named "torcs". Let's get some more information on this game.

apt-cache show torcs

Hmmm... it seems interesting. But is this game not already installed on my computer? And what is the available version? Which repository is it from (Universe or Main)?

apt-cache policy torcs

Ok, so now, let's install it!

apt-get install torcs

What is the command I must type in the console to launch this game? In this example, it's straightforward ("torcs"), but that's not always the case. One way of finding the name of the binary is to look at what files the package has installed in "/usr/bin". For games, the binary will be in "/usr/games". For administrative programs, it's in "/usr/sbin".

dpkg -L torcs | grep /usr/games/

The first part of the command display all files installed by the package "torcs" (try it). With the second part, we ask to only display lines containing "/usr/games/".

Hmmm, that game is cool. Maybe there are some extra tracks?

apt-cache search torcs

But I'm running out of space. I will delete the apt cache!

apt-get clean

Oh no, my mother asked me to remove all games from this computer. But I want to keep the configuration files so I can simply re-install it later.

apt-get remove torcs

If I want to also remove config files :

apt-get purge torcs

Setting up apt-get to use a http-proxy

These are three methods of using apt-get with a http-proxy.

Temporary proxy session

This is a temporary method that you can manually use each time you want to use apt-get through a http-proxy. This method is useful if you only want to temporarily use a http-proxy.

Enter this line in the terminal prior to using apt-get (substitute your details for yourproxyaddress and proxyport).

export http_proxy=http://yourproxyaddress:proxyport

If you normally use sudo to run apt-get you will need to login as root first for this to work unless you also add some explicit environment settings to /etc/sudoers, e.g.

Defaults env_keep = "http_proxy https_proxy ftp_proxy"

APT configuration file method

This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you only want apt-get (and not other applications) to use a http-proxy permanently.

IconsPage/info.png On some installations there will be no apt-conf file set up. This procedure will either edit an existing apt-conf file or create a new apt-conf file.

gksudo gedit /etc/apt/apt.conf

Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).

Acquire::http::Proxy "http://yourproxyaddress:proxyport";

Save the apt.conf file.

BASH rc method

This method adds a two lines to your .bashrc file in your $HOME directory. This method is useful if you would like apt-get and other applications for instance wget, to use a http-proxy.

gedit ~/.bashrc

Add these lines to the bottom of your ~/.bashrc file (substitute your details for yourproxyaddress and proxyport)

export http_proxy

Save the file. Close your terminal window and then open another terminal window or source the ~/.bashrc file:

source ~/.bashrc

Test your proxy with sudo apt-get update and whatever networking tool you desire. You can use firestarter or conky to see active connections.

If you make a mistake and go back to edit the file again, you can close the terminal and reopen it or you can source ~/.bashrc as shown above.

source ~/.bashrc

How to login a proxy user

If you need to login to the Proxy server this can be achieved in most cases by using the following layout in specifying the proxy address in http-proxy. (substitute your details for username, password, yourproxyaddress and proxyport)


Recommended Links

Google matched content

Softpanorama Recommended

Top articles


Top articles





Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy


War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes


Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law


Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haterís Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D

Copyright © 1996-2021 by Softpanorama Society. was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site


The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: December, 24, 2018