Add Extra Repositories

Software packages and programs are freely available for download at multiple online sites with standardized structures, called repositories. There are repositories officially sanctioned and monitored by the Kubuntu/Ubuntu developer community, while other repositories are independently provided, without official sanction or supervision (and should be used with caution). Additional information is available from the Ubuntu Repository Guide.

Types of Repositories

There are four major package repository types in Ubuntu:

main - Supported by Canonical. This is the major part of the distribution.

restricted - Software not licensed under the GPL (or similar software license), but supported by Canonical.

universe - Software licensed under the GPL (or similar license) and supported by users.

multiverse - Software not licensed under the GPL (or similar license), but supported by users.

There are also these additional types of repositories:

Saucy-updates - Updates to official packages.

Saucy-backports - Current version software from Terrific Tiger (Saucy+1) that have been backported to Saucy Salamander.

Saucy-proposed - Proposed updates & changes (bleeding edge stuff).

Third party repositories

Software developers often maintain their own repositories, from which software packages can be downloaded and installed directly to your computer (if you add the repository to your list). Many of these third party repositories and software packages have never been reviewed by the (K)Ubuntu/Debian community and can present a security risk to your computer. Trojans, backdoors, and other malicious software can be present at any unregulated repository. When using repositories not endorsed by the (K)ubuntu/Debian community, make sure you have utter confidence in that site before enabling the repository and installing a software package from it.

PPA repositories

A Personal Package Archive (PPA) is a special software repository used for experimental source packages still under development. Such software has not been approved by the Debian or Ubuntu developers (but may eventually become an accepted package). Use this software at your own risk just like any other third party repository software.

Note: If add-apt-repository is not available on your system, then install it with the package:

sudo apt-get install python-software-properties

Edit the repository sources list

This is an optional, labor intensive method. Do this at your own risk. Modify the default Ubuntu sources.list only if you understand what you're doing. Mixing repositories can break your system. For more information see the Ubuntu Command-line Repository guide.

Note: wget - retrieves a file from a network location. --quiet = no output. -O = Output downloaded item to terminal. The | (pipe symbol) is used to capture the output from the previous command (in our case the screen) and use it as an input for the piped command (i.e. apt-key, which adds it to the keyring).

Alternatively (and perhaps more easily), you can use apt-key directly:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY

where KEY is the missing key code printed in apt-get output, e.g. EF4186FE247510BE.

Installing .deb packages

Debian (.deb) packages are the packages that are used in Ubuntu. You can install any .deb package in your system. .deb files can generally be installed from your file manager (Nautilus) merely by clicking on them, since file associations with the default installer is already set in Ubuntu. These instructions are for those who wish to install packages from the command-line terminal (Terminal).

Install a downloaded Debian (Ubuntu) package (.deb):

sudo dpkg -i packagename.deb

Remove a Debian (Ubuntu) package (.deb):

sudo dpkg -r packagename

Reconfigure/Repair an installed Debian (Ubuntu) package (.deb):

sudo dpkg-reconfigure packagename

Example:

sudo dpkg-reconfigure mpd

Handling (Tar/GZip) and (Tar/Bzip2) archives

(Tar/GZip) archives end in ".tar.gz" and (Tar/Bzip2) archives end in ".tar.bz2". Bzip2 is the newer, more efficient compression method. These files can generally be automatically extracted by merely clicking on them from your file manager (Nautilus), since file associations with the appropriate archival utilities are set by default in Ubuntu. These instructions are for those who wish to use the command line Terminal.

To extract:

tar xvf packagename.tar.gz

Note: tar is an application which can extract files from an archive, decompressing if necessary.

-x means extract.

-v means verbose (list what it is extracting).

-f specifies the file to use.

Decompressing ".gz" files

gunzip file.gz

Decompressing ".bz2" files

bunzip2 file.bz2

Note: You can also decompress a package first by using the command gunzip (for .gz) or bunzip2 (for .bz2), leaving the .tar file. You would then use tar to extract it.

To create a .gz archive:

tar cvfz packagename.tar.gz folder

To create a .bz2 archive:

tar cvfj packagename.tar.bz2 folder

Installing a package from source

Make sure you have all the necessary development tools (i.e. libraries, compilers, headers):

sudo apt-get install build-essential linux-headers-$(uname -r)

Note: "uname -r" lists the current kernel you are using

Extract the archive that contains the source files:

tar xvf sourcefilesarchive.tar.gz

Build the package using the package's script (in this case the configure script), compile the package (make), and install the compiled package into your system (make install):

Note: typing ./ before a filename in the current folder allows the Linux shell to try and execute the file as an application even if it is not in the path (the set of folders which it searches when you type a command name). If you get a "permission denied" error, the file is not marked as being executable. To fix this:

sudo chmod +x filename

Example: In the above instructions, configure is the shell script to build the package from source. To be sure the configure script is executable:

sudo chmod +x configure

Create a .deb package from source files

If your build from source is successful, you can make a Debian (Ubuntu) package (.deb) for future use:

Install package tools:

sudo apt-get install checkinstall

Rebuild package using "checkinstall":

cd /path/to/extracted/package
./configure
sudo make
sudo checkinstall

Keep the resulting ".deb" file for future use. It can later be installed using:

sudo dpkg -i packagename.deb

Note: These are basic instructions that may not always work. Some packages require additional dependencies and optional parameters to be specified in order to build them successfully. Also see these Ubuntu wiki instructions. More info about .deb package structure can be found here.

Aptitude

Aptitude is a terminal-based package manager that can be used instead of apt-get. Aptitude marks packages that are automatically installed and removes them when no packages depend on them. This makes it easy to remove applications completely.
To use Aptitude, replace apt-get with aptitude in the command line. Example:

Synaptic Package Manager

While "apt-get" and "aptitude" are fast ways of installing programs/packages, you can also use the Synaptic Package Manager (Menu -> System -> Administration -> Synaptic Manager), a GUI method for installing programs/packages. Most (but not all) programs/packages available with apt-get install will also be available from the Synaptic Package Manager. This is the preferred method for most desktop users. In this guide, when you see

sudo apt-get install package

you can simply search for package in Synaptic and install it that way.

Menu -> System -> Administration -> Synaptic Package Manager

Search for the name of the program/package. You can also search for a word in its description.

-> Mark for Installation -> Apply

The selected program(s) will be automatically installed, along with its dependencies.

Ubuntu Software Center (Add/Remove Programs)

Not all packages available from apt-get, aptitude, and Synaptic Package Manager are available in the Ubuntu Software Center. However, it is the easiest interface for new users of Ubuntu and directs them to preferred packages.

Menu -> Applications -> Ubuntu Software Center

Search for the sort of program you want to add. Example: type MP3 to see a list of mp3 software.

Automated Updates

Repair broken packages

If a package installation fails (which can cause a Package Manager to freeze or become locked), or if a package has unsatisfied dependencies causing a similar condition, then run one (or both) of the following commands from the command-line terminal:

sudo apt-get install -f
sudo dpkg --configure -a

If a problem occurs with MergeList (appearing as a missing "Package: header" error):

E: Encountered a section with no Package: header
E: Problem with MergeList...
E: The package lists or status file could not be parsed or opened.

then repair by recreating the package lists:

sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update

If a problem occurs with a lock on the apt cache, for example:

E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)