Differences between revisions 52 and 53
Revision 52 as of 2018-08-02 06:39:08
Size: 17169
Comment:
Revision 53 as of 2018-08-02 06:51:23
Size: 17036
Comment: Add basic info on what packages mean
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
What are the packages? You may know them as Firefox, GIMP, etc and they are, but what they really are just lots and lots of files that have been compiled into one. The people (or sometimes a single person) that write this software are known as upstream providers, they compile their code and write up how to get it installed. These upstream providers work on getting out new software and update existing software. When they are ready to release it to the world, they send their package to package maintainers, who handle getting this piece of software in the hands of the users. These package maintainers review, manage and distribute this software in the form of packages. How do packages that get uploaded to the internet somehow end up on our computers? Do you go to the download page of each package you want and click download and install? Well, actually you can do that, but there is something better-called package repositories. Repositories are just a central storage location for packages. There are tons of repositories that hold lots of packages and best of all they are all found on the internet, no silly installation disks. Your machine doesn't know where to look for these repositories unless you explicitly tell it where to look. Your distribution already comes with pre-approved sources to get packages from and this is how it installs all the base packages you see on your system. On a Debian system, this sources file is the "/etc/apt/sources.list" file. Your machine will know to look there and check for any source repositories you added. You may know some software as Firefox, GIMP, etc, but what they really are just lots and lots of files that have been compiled into one. The people (or sometimes a single person) that write this software are known as upstream providers, they compile their code and write up how to get it installed. These upstream providers work on getting out new software and update existing software. When they are ready to release it to the world, they send their package to package maintainers, who handle getting this piece of software in the hands of the users. These package maintainers review, manage and distribute this software in the form of packages. So instead of downloading packages/software one by one from random sites (unlike Windows), there is something better-called package repositories in Debian. Repositories are just a central storage location for packages. There are tons of repositories that hold lots of packages and best of all they are all found on the internet, no silly installation disks. Your machine doesn't know where to look for these repositories unless you explicitly tell it where to look. Your distribution already comes with pre-approved sources to get packages from and this is how it installs all the base packages you see on your system. On a Debian system, this sources file is the "/etc/apt/sources.list" file. Your machine will know to look there and check for any source repositories you added.

Translation(s): English - español - Français - Italiano - 한국어(Korean)


You may know some software as Firefox, GIMP, etc, but what they really are just lots and lots of files that have been compiled into one. The people (or sometimes a single person) that write this software are known as upstream providers, they compile their code and write up how to get it installed. These upstream providers work on getting out new software and update existing software. When they are ready to release it to the world, they send their package to package maintainers, who handle getting this piece of software in the hands of the users. These package maintainers review, manage and distribute this software in the form of packages. So instead of downloading packages/software one by one from random sites (unlike Windows), there is something better-called package repositories in Debian. Repositories are just a central storage location for packages. There are tons of repositories that hold lots of packages and best of all they are all found on the internet, no silly installation disks. Your machine doesn't know where to look for these repositories unless you explicitly tell it where to look. Your distribution already comes with pre-approved sources to get packages from and this is how it installs all the base packages you see on your system. On a Debian system, this sources file is the "/etc/apt/sources.list" file. Your machine will know to look there and check for any source repositories you added.

Packages very rarely work by themselves, they are most often accompanied by dependencies to help them run. For example, let's say we have a group of restaurants, these restaurants all make different cuisine, however they all get their ingredients from the same farm. Their food is dependent on the farm's supplies, if the farm were to suddenly stop supplying food, well then the restaurants would be in a pretty bad state.

In Linux, these dependencies are often other packages or shared libraries. Shared libraries are libraries of code that other programs want to use and don't want to have to rewrite for themselves. Think of the restaurant again, how much work would it be if every restaurant also farmed their own food? Too much. The package management system binds all the software on a Debian system together. Debian uses named "packages" for each piece of software, bundles of files which provide the files to be installed on the system, the dependencies between packages and the configuration of the software. These packages can be installed or removed (unless, of course, some other package requires it) at will. In fact, the majority of the Debian installation process is installing the most basic packages that allow Debian to function.

Debian package management consists of several layers. The lowest layers, most of which you won't want to touch, are made up of dpkg and associated programs. On top of those layers are the Apt and apt-get tools as well as the newer aptitude tool. The Package Management Tools page has brief descriptions of these and other tools which work with DebianPackage files.

All of those tools are documented by a ManPage, so if you have questions, you should consult them (eg. 'man apt'). If you're new, there are some commands that have proven most useful for everyday use. They are grouped generally as:

Full-Screen Frontends

These are both console (ncurses) and GUI based. There are a number of alternatives, similar in some regards, different in others. For users of RPM-based Linux distros, analogs include RedCarpet and Up2Date.

  • aptitude may be invoked in full-screen console mode (ncurses) or CLI mode, and is a friendly frontend to apt.

  • DSelect is an older frontend to apt. It is no longer recommended.

  • Synaptic is another GUI-based frontend.

  • Apper is one more GUI front-end (KDE-based). The front-end is based on packagekit.

Command-line Frontends

  • apt
  • aptitude
  • apt-get

Generally, the command line tools integrate a number of operations (package list management, package retrieval, package installation, package configuration) in a single command plus arguments. The primary command line tool is aptitude. The higher level utility apt-get fulfills a similar purpose and although it is no longer the recommended primary tool, some still use it. Here are some typical invocations:

  • aptitude update (or apt-get update, see apt-get) to update apt's internal database of available packages

  • aptitude safe-upgrade (or apt-get -u upgrade) to bring all currently installed packages up to date

  • aptitude search jabber (or apt-cache search jabber) to find a program that gives you access to the jabber instant-messaging system

  • aptitude show gabber (or apt-cache show gabber) to display more info about the GNOME jabber client

  • aptitude install gabber (or apt-get install gabber) to install the package

  • aptitude remove gabber (or apt-get remove gabber) to remove it again

  • aptitude search '~i' to show installed packages

Apt

  • Purpose

apt provides a high-level command line interface for the package management system. With apt, you get all the necessary tools in one place. You won’t be lost under tons of command options. The main aim of apt is to provide an efficient way of handling package in a way “pleasant for end users”, means that it has fewer but sufficient command options but in a more organized way. On top of that, it enables a few options by default that is actually helpful for the end users.

apt has numerous advantages over other package management tools available in Debian for server administrators. Some of these advantages include ease of use over simple terminal connections (SSH), and the ability to be used in system administration scripts, which can, in turn, be automated by the cron scheduling utility. Some instances of apt usages are:

  • Update

To download package info from all configured sources, the following command can be issued:

$ sudo apt update
  • Search

Packages can be searched via:

$ apt search <packagename>
  • Show

To see detailed information about a package:

$ apt info <packagename>
  • Regular package handling:

adding, removing packages are simple as:

$ sudo apt install firefox
$ sudo apt remove firefox
$ sudo apt install </path/to/deb/file/debfile.deb>

Note

apt performs the requested action on one or more packages specified via regex, glob or exact match. The requested action can be overridden for specific packages by appending a plus (+) to the package name to install this package or a minus (-) to remove it.

A specific version of a package can be selected for installation by following the package name with an equals (=) and the version of the package to select. Alternatively, the version from a specific release can be selected by following the package name with a forward slash (/) and codename (stretch, buster, sid...) or suite name (stable, testing, unstable). This will also select versions from this release for dependencies of this package if needed to satisfy the request. Removing a package removes all packaged data, but leaves usually small (modified) user configuration files behind, in case the remove was an accident. Just issuing an installation request for the accidentally removed package will restore its function as before in that case. On the other hand, you can get rid of these leftovers by calling purge even on already removed packages. Note that this does not affect any data or configuration stored in your home directory.

  • Autoremove

autoremove is used to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed as dependencies changed or the package(s) needing them were removed in the meantime. The command for autoremove is simple as:

$ sudo apt autoremove

It can also be issued while removing the package like this:

$ sudo apt remove clang --auto-remove

You should check that the list does not include applications you have grown to like even though they were once installed just as a dependency of another package. You can mark such a package as manually installed by using "sudo apt mark set auto/manual foo". Packages which you have installed explicitly/directly via install are also never proposed for automatic removal.

  • Upgrade

To upgrade all locally installed packages:

$ sudo apt upgrade
  • full-upgrade

It performs the function of the upgrade but will remove currently installed packages if that is essential to upgrade the system as a whole. This command is usually issued while doing system upgrades.

$ sudo apt full-upgrade
  • Edit Sources

There is a cool new feature of apt that allows edit package sources, i.e. "sources.list" files in your preferred editor while providing basic sanity checks. Command to be issued:

$ sudo edit-sources

You can also use Wajig, for a unified and more logical command-line interface to all package management functions.

Low-level Tools

Largely dpkg and friends, these are commands that perform a single task. They are most directly comparable to Redhat's "rpm" command.

  • dpkg-reconfigure locales to reconfigure Locales

  • dpkg-reconfigure exim to reconfigure the exim mail-transfer agent. This command isn't currently part of dpkg; it's provided by debconf.

  • dpkg, (see DPkg) invoked with various command-line arguments. If you find a place to download debian-packages that is not accessible via apt, you can download the packages and install them directly. Note that this method will not automatically resolve dependencies between packages etc, therefore use apt or dselect if possible.

  • dpkg --listfiles textutils to list all the files provided by the textutils package. This only works for packages which are already installed. This can be useful to find out what form a package's documentation has been provided in.

  • dpkg -S /path/to/some/file to find out which package a file belongs to.

  • deborphan can be handy but is no longer required to recover space because apt now automatically un-installs unneeded packages that were installed only to satisfy a dependency of a package that was specifically requested to be installed but has since been removed. It gives you a list of library packages that no longer have higher-level packages depending on them.

Contents of a debian file

To see the contents of debian packages in the Debian repositories, whether installed or uninstalled, install the apt-file package and enter

$ apt-file update
$ apt-file list foo

To get the contents of the file "abc.deb", you have to enter

$ dpkg-deb -c abc.deb

Reconfiguring of debconf

To reconfigure debconf, so that it informs you of most changes of the new packages, you have to enter (as Root):

 # dpkg-reconfigure debconf

Chose "medium" here

Package Management with apt-get and dpkg

Package resource list for APT

The file /etc/apt/sources.list is the definition file of the sources for apt. For further information about this file type

$ man 5 sources.list

Retrieve new lists of packages:

To fetch the new lists of all the packages from sources.list enter:

# aptitude update

or the equivalent

# apt-get update

This command checks for new release-files on the given servers. Luckily the command is clever enough to check if the release-file has changed after the last update.

Upgrade of all the files:

To make an update of all the changed packages, enter the line

# aptitude safe-upgrade

If you want to do this from cron you should consider using the cron-apt package.

The older apt-get based method is:

# apt-get upgrade -u

The additional flag -u shows a list of upgraded packages as well. If you want to run the update in a cron-job, you should use the flag -dy. With this flag, the new packages will be downloaded but not installed. You can install them later by writing apt-get update -u.

Distribution Upgrade of all the files:

WARNING

Following the upgrade instructions found in the release notes is the best way to ensure that your system upgrades from one major Debian release to another (e.g. from lenny to squeeze) without breakage!

These instructions will tell you to do a dist-upgrade (instead of upgrade) at least once. You would have to type something like

# apt-get dist-upgrade -dy

# apt-get dist-upgrade -u

at some point during the major release upgrade.

A dist-upgrade will also be required to keep up-to-date with the latest version in testing and unstable. A dist-upgrade may be very occasionally needed for you to obtain security upgrades in stable releases too in the case where packages change names.

Discover a package:

How can you discover which package to use without the GUI programs?

# apt-cache search sylpheed

Or use a web interface:

http://packages.debian.org/search?sylpheed

With the web search interface you can search the package contents for specific files:

http://packages.debian.org/search?suite=default&section=all&arch=any&searchon=contents&keywords=bin%2Fsylpheed

Add a package:

How can you add a package to your system without the GUI programs? All you have to do is find out the name of this package and enter the command

# aptitude install sylpheed-claws

or

# apt-get install sylpheed-claws

to add the package sylpheed-claws.

Remove a package:

To get rid of the package foo which is no longer needed, enter the command

# aptitude remove foo

or

# apt-get remove foo

Removing a package removes all packaged data, but leaves usually small (modified) user configuration files behind, in case the remove was an accident. Just issuing an installation request for the accidentally removed package will restore its function as before in that case. On the other hand, you can get rid of these leftovers by calling purge even on already removed packages. Note that this does not affect any data or configuration stored in your home directory.

So, technically if the package is needed by other packages you will be prompted to remove this package and all packages which depend on it. Also just removing a package does not remove the configuration files that relate to the package. To get rid of the package foo which is no longer needed along with all configuration files and related dependencies, enter the command:

# apt-get purge --autoremove foo 

You can also use the command below to purge configuration files after issuing a normal by apt-get remove foo:

# apt-get purge $(dpkg -l | awk '/^rc/ { print $2 }')

Warning

Careful while removing packages. Pay attention to apt messages.

Forcing removal of a package:

While making a distribution upgrade it could happen that you have to remove a package first. But sometimes this is not possible with apt-get remove since the package has unmet dependencies or is not installed completely. You can remove the package foo by using the command

# dpkg --force-all --remove foo

Read the contents of a installed package:

Sometimes you want to know which files are in the package foo. To get this information enter the command

$ dpkg -L foo

Get the description of a package:

You don't know what the package foo is for? Just write

$ aptitude show foo

or

$ dpkg -p foo

Search the package of a file:

Have you ever wondered to which package a given file belongs? To get this information (e.g. for /usr/bin/apt-get), start the command

$ dpkg -S /usr/bin/apt-get

and it will tell you that this file is part of the package apt.


?CategoryQuickPackageManagement | CategoryPackageManagement