Как установить локальный .deb пакет
Файлы с расширением .deb — это установочные пакеты для Debian и производных дистрибутивов, для таких, как Linux Mint, Kali Linux, Ubuntu.
Типичный способ установки пакета из файла DEB:
С помощью этих команд устанавливаются пакеты из стандартных репозиториев — это самый надёжный способ в том плане, что для устанавливаемого пакету будут установлены зависимости и в будущем этот пакет будет обновляться вместе с другими программами в системе. То есть установка из стандартных репозиториев является приоритетной.
Установка скаченных .deb
Иногда может потребоваться установка локальных .deb, то есть файлов не из репозиториев. Примеры, когда потребовалась такая установка:
- Как установить Viber на Linux (необходимо отредактировать пакет Viber, иначе его установки приведёт к проблемам к использованию менеджеров пакетов)
- Как установить Java (JDK) в Windows и Linux (Oracle JDK отсутствует в стандартных репозиториях)
Установка без учёта зависимостей
Следующая команда установит пакет без проверки зависимостей:
При выполнении операции менеджером пакетов, например, обновление кэша:
может возникнуть сообщение об отсутствующих зависимостях, исправить это можно командой:
Установка DEB файла с помощью apt
Программа apt также умеет устанавливать пакеты из указанных файлов, при этом одновременно будут установлены необходимые зависимости для этого пакета:
Установка пакетов с помощью gdebi
Вы можете установить программу gdebi:
И затем устанавливать пакеты с помощью неё:
gdebi также установит необходимые зависимости. На самом деле, gdebi появилась когда apt-get не могла устанавливать локальные файлы (или эта возможность не была документирована), сейчас же вместо gdebi можно использовать apt, которая предустановлена в каждом дистрибутиве, основанном на Debian.
Как установить deb пакет в debian
Advanced topics on Debian package management
Debian package management consists of several layers. The lowest layers are made up of dpkg and associated programs. On top of these layers is the Apt family of tools such as apt, apt-get, apt-cache, and others. See the Package Management Tools page for a description of other tools for working with DebianPackage files.
- Apt
- Update your package lists
- Upgrading your system
- Installing and removing packages
- Finding packages
- Clean up
- Editing Sources
- Package resource list for APT
- Retrieve new lists of packages:
- Upgrade of all the files:
- Distribution Upgrade of all the files:
- Discover a package:
- Add a package:
- Remove a package:
- Forcing removal of a package:
- Read the contents of a installed package:
- Get the description of a package:
- Search the package of a file:
You may know some software like Firefox, GIMP, etc, but what they really are is 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 new software out 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 (like on Windows), there is something better — called package repositories in Debian.
Repositories are just a central storage location for packages. Many online repositories hold lots of packages. Your machine doesn’t know where to look for these repositories unless you explicitly tell it where to look. Debian 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 (if a user did a net-install). 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.
apt provides a high-level command line interface for debian’s package management system, with all the necessary tools in one place. apt aims to provide a simple, efficient way of handling packages for end users.
Update your package lists
To use apt, it is important to retrieve a fresh copy of the package lists from the configured sources:
Upgrading your system
You should upgrade you system everyday, this gives you security and bug fixes:
Sometimes it is helpful to use "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.
Before upgrading your Debian system to the next release, drop into a "tty" console by pressing CTRL+ALT+F3/F4/F5 etc, as dpkg restarts some login managers that will forcefully log you out while upgrading, resulting in a broken/partial upgrade
Installing and removing packages
To install a package, in this example Firefox:
To remove a package:
You can also install a .deb file with:
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 code name (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 the users’ home directory.
Finding packages
Search for a package:
For example, to find packages with the term ‘cats’ in the package name or description:
To see detailed information about a package:
Clean up
After you remove a package, you should remove any other packages that were automatically installed to satisfy dependencies and are now no longer needed:
It can also be issued while removing a package like:
You should check this 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 apt install foo or apt-mark auto/manual foo. Packages which you have installed explicitly/directly via install are also never proposed for automatic removal.
Editing Sources
There is a cool new feature of apt that allows editing package sources, i.e. "sources.list", in your preferred editor while providing basic sanity checks:
See SourcesList on how to configure your sources.
Low-level Tools
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
To get the contents of the file "abc.deb", you have to enter
Reconfiguring of debconf
To reconfigure debconf so that it informs you of most changes of the new packages:
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
Retrieve new lists of packages:
To fetch the new lists of all the packages from sources.list enter:
or the equivalent
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
If you want to do this from cron you should consider using the cron-apt package.
The older apt-get based method is:
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 jessie to stretch) 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
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?
Or use a web interface:
With the web search interface you can search the package contents for specific files:
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
to add the package sylpheed-claws.
Remove a package:
To get rid of the package foo which is no longer needed, enter the command
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:
You can also use the command below to purge configuration files after issuing a normal by apt-get remove foo:
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
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
Как установить DEB пакет в Debian и производных

Даже если вы новичок в Linux и работаете с ним совсем не долго, вы знаете, что самый распространенный способ установки программ в дистрибутивах, основанных на данном ядре, это установка из репозиториев. Однако, бывают случаи, когда это невозможно, а нужная программа распространяется в виде пакета rpm или deb. И поскольку более распространенными на сегодняшний день являются дистрибутивы, основанные на Debian (Ubuntu, Elementary OS, Linux Mint и т.п), в которых используются deb пакеты, рассмотрим как устанавливать именно их.
Установка deb пакета в Ubuntu
В Ubuntu установить deb пакет можно через Центр приложений:
- скачайте нужный файл;
- кликните по нему два раза левой клавишей мыши;
- в открывшемся Центре Приложений выберите “Установить”.
Установка deb пакета через терминал
Как всегда, самый простой и универсальный способ как для настройки Linux, так и установки deb пакетов в частности, это терминал. Чтобы установить deb пакет через терминал достаточно выполнить несколько команд. Рассмотрим на примере установки Google Chrome:
- естественно, сначала скачиваем сам пакет;
- дальше открываем терминал и переходим в каталог с файлом, поскольку чаще всего это “Загрузки”, то команда будет выглядеть так:
- и выполняем установку при помощи пакетного менеджера dpkg:
- вводим пароль суперпользователя и ждем окончания установки.
То есть, для установки deb пакета через терминал нужно использовать конструкцию:
Debian Package Tutorial (dpkg/.deb)
Debian Package tool dpkg is used on Debian, Ubuntu, Kali, Linux Mint, and other Debian based Linux distributions. This tutorial covers the basics of creating custom .deb packages and managing them with dpkg and apt . We will cover the process of creating your own deb file to distribute your package easily. It is aimed at people who are interested in learning the basics of creating and managing packages in Debian based distributions. Read more about The .deb file format
A .deb file is a Debian package, but really it is just a standard Unix archive ( .ar ) file. The dpkg tool is the Debian package manager and apt is a higher level tool for managing packages which uses dpkg under the hood.
List installed packages
List packages with dpkg or apt :
Create a package
You can make and distribute your own .deb package very easily. To start fresh, create a new directory named after your package. For example, mypkg . This directory will store the package metadata and the package contents. Inside the project directory, there needs to be one special directory ( DEBIAN ) with one special file inside it ( control ).
A more practical example with a post-installation script:
This is a minimal example of the DEBIAN/control file:
The Depends line is optional, but frequently needed. The example above shows how to add multiple dependencies, how to specify a minimum version with python3, and how to add a dependency that is satisfied by one of many options. There are many versions of java listed and any one will satisfy the requirement. If none of them are installed, it will start from the first one in the list and try to install it. This way, it will work if the user has version 8 of the JDK or JRE in full or headless variant. If none of them are installed it will install the smallest version (the headless jre).
Build the package by running dpkg -b on the project directory like this:
It’s a special little package, but it’s lonely without any files to install. Normally a package has some contents like a shared library, man pages, documentation, an executable program, or systemd service files.
The next thing we’ll need to do is add files to the package. Some examples of things you might include are:
- an executable or a shell script launcher in /usr/local/bin/
- man pages in /usr/share/man
- configuration files in /etc/
- libraries in /usr/local/lib
- header files in /usr/local/include
In this example, we’ll add a shell launch script for a Java JAR file:
Be sure to chmod +x the script and place it in the mypkg/usr/local/bin/ directory.
Configuration files
List configuration files in DEBIAN/conffiles This will allow configuration files to optionally remain when uninstalling (remove vs purge). It also prevents updates from overwriting configuration files.
Pre/post install scripts
An example DEBIAN/postinst script:
Package interrelationships
There are some other variables you can specify in the control file:
- Depends
- Recommends
- Suggests
- Breaks
- Conflicts
- Provides
- Replaces
- Enhances
These can be useful to warn people if your package conflicts with another package that is already installed. You can also replace or enhance existing packages. If other packages would make your package work better, you can recommend and suggest other packages when the user installs your package.
Print package information
You can use dpkg and apt-cache to get some information about packages.
Print package contents
If you want to review the contents of a .deb package before installing it, you can print the contents with the -c flag.
Extract package contents
If you want to extract the contents of a .deb file, use the -X flag for verbose extraction, or -x for quiet extraction.
Install a package
Usually, two options are available for installing .deb packages. One is dpkg and the other is apt which is built on top of dpkg .
If you don’t have the dependencies installed you will have to install them yourself if you use dpkg -i . Alternatively, you can use apt . I recommend using apt because it still uses dpkg under the hood, but it handles dependencies and is more user-friendly.
Searching for packages in apt repositories
You can use apt-cache to search for packages in your apt repositories. These will need to be installed with apt install though not dpkg .
Search like this:
Uninstall a package
You can uninstall a package using remove but it will leave the configuration files. To also remove the configuration files, use purge .
Listing files that belong to a package
This can be useful when trying to figure out what the executable file names are in /usr/bin or when trying to find local documentation.
Find which package owns a file
If you have a file on your system and you want to see if it belongs to a package, you can use dpkg -S <filepath> to see which package owns it.
You can also use apt-file search <filename> to see which packages in the repositories contain a file with that name.
For example «What package created this /etc/qwerty.conf file?» or «Which package owns this executable?», or «Which packages do I need to install to get gl.h ?» can be answered with:
Security notes
Only Use trusted packages and repositories only. You install packages with root privileges and you will be giving full reign on your machine with a package. Do not run any package you are not 100% confident it is from a trusted source.
GPG signing is a good way to ensure integrity and authenticity, that is, it has not been modified and the package came from the expected author.
You can learn more about how to sign files with GPG in my GPG Basics Tutorial. GPG is a great cryptography tool to be familiar with and worth taking the time to learn it. You can also use it to encrypt emails so only the intended recipient can read it, encrypting archives or PDFs, verifying signatures from others, and and many other practical uses.
Convert a .deb to .rpm and other formats
If you need a RedHat .rpm file to install in CentOS, RedHat, or Fedora, you can use the alien tool to convert packages. http://joeyh.name/code/alien/
Some other options are:
Debhelper tool
I do not have much experience with this tool but it is worth a mention. The debhelper tool provides some utility and code generation features. Here is how you can install it and explore more.
Conclusion
You should now feel comfortable working with and creating your own Debian packages, how to get information about a package, how to find which package a file belongs to, and other common tasks.