Debian Package Management Using apt-get

Posted on April 21, 2008

Heres a tutorial on how to use the apt-get package management system in Debian and its derivitives such as Ubuntu and Knoppix. I will cover command line use of apt-get, the aptitude program and the Synaptic Package Manager. I wrote all of this myself, feel free to link to here but do not copy and paste it.

Debian uses apt-get package management. It looks at a series of defined repositories (servers) for the package(s) you want and will download them if they are there. The repositories are defined in the file

/etc/apt/sources.list

You can edit that file directly (make sure you have root) or use frontends like the Synaptic Package Manager or Software Sources (Menu item) in the distro.

Command Line Usage

To install a package you need to use the apt-get install command. For example to install the IRC program XChat you would type into the console.

sudo apt-get  install xchat

It would prompt you for your root password and then list information about the package and would double check you still want to download and install it.

To remove a package you would use the apt-get remove command. This will remove the package files but will keep the configuration files incase you install the same application at a later date. If you wanted to remove XChat you would type into the console.

sudo apt-get remove xchat

To completely remove a package and leave no trace of it you would use the apt-get –purge remove command. If you wanted to completely remove XChat you would type into the console.

sudo apt-get –purge remove xchat

To upgrade packages on your system you would use the apt-get -u upgrade command. This would update all your packages but before updating them, would list them for you to see. If you wanted to update packages on your system you would type into the console.

sudo apt-get -u

To do a complete distro upgrade (Eg upgrade from Ubuntu Fiesty Fawn to Ubuntu Gutsy Gibbon then you would use the apt-get -u dist-upgrade command. Its considered to be good practice in reinstalling your system when a new release comes out or only dist-upgrade once or twice. It can lead to breaks in the OS and sluggishness. If you wanted to dist-upgrade your system you would type into the console.

sudo apt-get -u dist-upgrade

Again, it would show you what packages you would be upgrading before actually starting.

Aptitude

aptitude is a Command Line/Basic GUI tool for installing packages using apt-get. If your still not comfortable with full command line usage but the Synaptic Package Manager takes up too much system resources on your system then aptitude might be right for you. You can start it with the command

sudo aptitude

It launches a basic GUI in the console in which you can browse packages by category and search for them.

Once you have found the package you want to install, you can confirm it and it will download and install it.

Synaptic Package Manager

The Synaptic Package Manager is one of the most widely used applications in Debian based systems. Its got a friendly and easy to navigate GUI. Like aptitude its really just an apt-get frontend but new users seem to like it.

Although it may seem basic, it provides updating, installing, removing, purging, searching and an editor for /etc/apt/sources.list all in one.

Leave a Reply

You must be logged in to post a comment.