Linux Command Line Syntax: The apt-get Command

Linux Command Line Syntax: The apt-get Command
Page content

What is apt-get?

The apt-get command is often considered a front end (even though most consider a “front end” to be a graphical application) for the APT package management system. The apt-get system uses a listing of repositories that keep track of what sites are available to download packages from. Alongside this is a database of applications installed on your system. With this combination, apt-get will know what you have installed vs what is available to install. The user can also add to the repository listing so more software titles are available.

Apt-get is issued from the command line by either the root user or using sudo. Apt-get can do the following:

  • install - Install applications onto your system.
  • upgrade - Upgrade already installed applications.
  • distribution upgrade - Upgrade to a newer distribution release.
  • remove - Uninstall applications
  • check - Checks for broken dependencies and updates package cache.

Basic Usage

As mentioned before, apt-get requires root (or sudo) privileges. To use apt-get you will first need to know the application you want to install. We will use aterm as an example. To install aterm with apt-get you would issue the command apt-get install aterm. To remove aterm with apt-get you would issue the command apt-get remove aterm.

Upgrading with apt-get

One of the limitations with apt-get is that you can not upgrade a single application. Instead, there are two ways to upgrade with apt-get:

  1. Do a full upgrade which will upgrade every package on your system.

  2. Do a distribution upgrade.

One word of advice here. Doing a major distribution upgrade (i.e. going from Ubuntu 7.10 to 8.04) is not always the best choice. A minor distribution upgrade (i.e. going from Ubuntu 8.04 to 8.10) is generally fine. So if you are running a .10 release in Ubuntu, and you want to upgrade packages, it is best to use apt-get upgrade over apt-get dist-upgrade.

Sources

If you look in the /etc/apt/sources.list you will see a listing of the current repository sources available to your machine. You can add to this list by editing the file with a text editor (such as nano.) The entries will look somewhat like this:

deb https://host/ distribution section1 section2 section3

deb-src https://host/ distribution section1 section2 section3

If there is an application that is not found with your current repository list, you most likely will have to do a search for the application’s apt repository. Sometimes a package will be found in various repositories such as the universe repository. There are a number of repositories that handle different packages. Ubuntu repositories can include:

  • main - This is the major part of the distribution.
  • restricted - Software not licensed under the GPL (or similar license).
  • 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.

Final Thoughts

The apt-get system is a very easy command line package management tool. Using this tool alongside Synaptic will ensure your system’s packages are managed as efficiently and as cleanly (and as simply) as they can be.

This post is part of the series: Simplify Linux application installation and archiving

If you are new to Linux than you might be baffled as to how to handle two important tasks: Application installation and directory archiving. Never fear, Bright Hub is hear. In this series of articles you will learn how to master the tools to help you tackle these tasks.

  1. Simplifying Linux Installation and Archiving
  2. Linux Command Line: apt-get
  3. Linux Command Line: urpmi
  4. Linux Command Line: rpm
  5. Linux Command Line: tar
  6. Linux Command Line: bzip2/bunzip2