How To Install Any Ubuntu Package Using Apt-Get

Install Software Using apt-get
Install Software Using apt-get.

 

Introduction

When people first start to use Ubuntu they will use the Ubuntu Software Manager to install software.

It doesn't take long however before it becomes obvious that the Software Manager isn't actually very powerful and not every package is available.

The best tool for installing software within Ubuntu is apt-get. It is a command line application which will instantly put some people off but it gives you so much more than any other tool at your disposal.

This guide shows how to find, install and manage applications using the apt-get command.

Open A Terminal

To open a terminal within Ubuntu press CTRL, Alt and T at the same time. Alternatively press the super key (Windows key) and type "term" into the search bar. Click the icon that appears for the terminal.

This guide shows how all the different ways there are to open a terminal within Ubuntu.

(Click here for a guide showing how to navigate Ubuntu using the launcher or here for a guide showing how to use the Dash)

Update The Repositories

Software is made available to users via repositories. Using the apt-get command you can access the repositories to list the packages that are available

Before you start searching for packages however you will want to update them so that you get the latest available list of programs and applications.

The repository is a snapshot in time and so as days pass new software versions become available which are not reflected in your repositories.

To keep your repositories up to date run this command before installing any software.

sudo apt-get update

Keep Installed Software Up To Date

It is highly likely that you will use the update manager to keep your software up to date but you can also use apt-get to do the same thing.

To do so run the following command:

sudo apt-get upgrade

How To Search For Packages

Before installing packages you will need to know which packages are available. apt-get is not used for this task. Instead, apt-cache is used as follows:

sudo apt-cache search <package name | keyword>

For example to search for a web browser type the following:

sudo apt-cache search "web browser"

To get more information about a package type the following:

sudo apt-cache show <package name>

How To Install A Package

To install a package using apt-get use the following command:

sudo apt-get install <package name>

To get a full idea of how to install a package follow this guide which shows how to install Skype.

How To Remove A Package

Removing packages is as straight forward as installing packages. Simply replace the word install with remove as follows:

sudo apt-get remove <package name>

 

Removing a package merely removes the package. It does not remove any configuration files used with that piece of software.

To fully remove a package use the purge command:

sudo apt-get purge <package name>

How To Get The Source Code For A Package

In order to view the source code for a package you can use the following command:

sudo apt-get source <package name>

The source code is placed into the folder where you ran the apt-get command from.

What Happens During The Installation Process?

When you install a package using apt-get a file with a .deb extension is downloaded and placed into the folder /var/cache/apt/packages.

The package is then installed from that folder.

You can clear the folders /var/cache/apt/packages and  /var/cache/apt/packages/partial  by using the following command:

sudo apt-get clean 

How To Reinstall A Package

If an application you are using suddenly stops working then it might be worth attempting to reinstall the package in case something has been corrupted somehow.

To do this use the following command:

sudo apt-get install <package name> --reinstall

Summary

This guide shows a summary of the most useful commands required to install packages using the command line within Ubuntu.

For a full usage summary read the man pages for apt-get and apt-cache. It is also worth checking out the man pages for dpkg and apt-cdrom.

This guide is item 8 on the list of 33 things to do after installing Ubuntu

More From Us