Debian installing deb packages from the console. How to build a binary deb package: detailed HowTo. Installing deb packages using gdebi

From time to time, new tasks appear, or the need to solve old problems in new ways - then the need for additional software arises. This article tells you what to do if you need a new program for Ubuntu.

In Ubuntu, as in other operating systems, there is a concept dependencies. This means that the program can only be installed if the packages on which it depends are already installed. This scheme allows you to avoid duplication of data in packages (for example, if several programs depend on the same library, then you do not have to shove this library into the package of each program - it will be installed once in a separate package). Unlike, for example, Slackware or Windows, in Ubuntu dependencies are resolved by a package manager (Synaptic, apt, Application Center, apt-get, aptitude) - it will automatically install dependencies from the repository. Dependencies will have to be installed manually if the required repository is not connected, is inaccessible, if the required package is not in the repository, if you install packages without using a package manager (use Gdebi or dpkg), if you install the program not from a package (compile from sources, run the installation run /sh script).

Installation from repositories

If you have not added local repositories (for example, CD/DVD disks), then you will need the Internet to install programs from the repositories.

This method of installing programs has many advantages: it is simply convenient, you install already tested programs that are guaranteed to work on your system, dependencies between packages will be resolved automatically, and when new versions of installed programs appear in the repository, you will be informed about this.

Using GUI

Select System → Administration → Synaptic Package Manager and get a more powerful tool for working with packages. In particular, you can, for example, install programs partially if, for example, you do not need documentation or something else. Launch Synaptic Package Manager System→Administration→Synaptic Package Manager. When prompted, enter your password. In the launched program, click the “Update” button, wait until the system updates the data about available programs.

In the list of available programs, double-click on the desired program (or right-click - select “Mark for installation”). Once all the desired programs are marked for installation, click the "Apply" button. Wait while the required packages are downloaded and installed. Similar functions are performed by the “Add or Remove Applications” program; it can be easily found in the menu Applications→Install/Uninstall…

Installing from the command line allows you to get more information about the installation process and allows you to flexibly customize it, although it may seem inconvenient to a novice user.

Using the command line

Launch the terminal (Menu: Applications - Accessories - Terminal). Installation is performed using the dpkg program

Sudo dpkg -i /home/user/soft/ntlmaps_0.9.9.0.1-10_all.deb

You will need to enter your password. Don't forget that the password is not displayed when you enter it in the terminal. Note that when using dpkg, you must enter the full file name (not just the program name). Read what dpkg outputs to the terminal - there will be either a message about successful installation, or a description of the error (for example, unmet dependencies). You can install several packages at once with one command, for example, the following command will install all deb packages in a directory:

Sudo dpkg -i /home/user/soft/ntlmaps_*.deb

This is useful for installing a software package along with dependency packages.

Prevent package update

There are times when it is unnecessary to install a package version newer than the installed one. For example, there is no support for something in the new version or it does not work correctly on the system.

Via dpkg

In the terminal:

Sudo echo "package_name hold" | sudo dpkg --set-selections

The package name is taken from the command you installed the package with. To allow updating, do this:

Echo "package_name install" | sudo dpkg --set-selections

Let's look at the package status:

Dpkg --get-selections | grep "package_name"

Via apt

Installing programs with their own installer from sh, run files

Sometimes programs can be distributed with their own installer. This is no different from the situation in Windows. Only here, after unpacking the tar.gz archive with the program distribution kit, instead of setup.exe you will see something like install.sh.

This is a pre-assembled software package, which is designed in the form of a script or binary; it takes on the work of placing files in the right places and specifying the necessary parameters. In this case, the ability to manage such software using a package manager is lost. It is not advisable to use such packages, but if there is no choice, then go to the directory with the file, for example:

Cd ~/soft

We allow this file to be executed:

Chmod +x install.sh

Let's launch it:

Sudo ./install.sh

Sometimes a program can be installed without superuser rights (without sudo), but this is rather an exception.

Sometimes the program distribution is distributed as a self-extracting archive. In this case, it will simply be one single .sh file that needs to be run. Then you will simply receive a wizard where you will need to answer a series of questions, just as it is done in Windows. This is how official nVidia, ATI drivers, NetBeans developer environment, etc. are installed.

There are programs that do not require installation and are distributed in the form of a regular tar.gz archive, which you just need to unpack somewhere. Windows also has such programs; they are often called Portable. There is no need to install such programs, just unpack them to any location, but the standard location is usually the /opt directory. Of course, you will have to add launch items to the menu manually; to do this, you need to right-click on the Programs menu title and select Edit menu.

Installation from source

If there are no deb packages for your system anywhere, then the program can be assembled (compiled) yourself from source codes, which can be downloaded from the official website of any program or from the distribution's source repository.

I recommend avoiding this method of installing programs if possible. The main thing you will need is tools for compilation, for this you first need to install the build-essential package. Next, you need to unpack the archive with the program codes into some temporary folder. Then you need to find the README or INSTALL file, read it and do what is written there. More often, installing programs in this way is limited to sequential execution of the following commands:

But in some cases there may be differences. In addition, after executing the ./configure script, you may receive a message that the system does not have the libraries necessary to compile the program installed. In this case, you will need to install them yourself and repeat the process. Usually the compilation process takes some time and directly depends on the power of your computer.

Like this. It is advisable, of course, to avoid installing programs if possible. Not using deb packages, that is, other methods are not recommended. However, you need to know them so as not to get confused in the flow of information.

Automatic installation of dependencies when building from sources

This type of installation is better than just ./configure && make && make install, and is suitable for installing programs that are not in the repositories.

Set auto-apt:

Sudo apt-get install auto-apt

Go to the folder with the unpacked sources and command:

Sudo auto-apt update && auto-apt -y run ./configure

The auto-apt command will deliver the necessary packages for the build itself, and will allow you to ask fewer questions.

Creating a deb package for easier work in the future (installation, removal, etc.).

Today I was thinking about what to do if there is no Internet access, but I need to install some program. After all, programs in Linux Ubuntu are installed from online repositories. By the way, this also works in Kubuntu, Lubuntu. I haven't checked the rest.
How can I get the deb packages necessary for installation? If there is no Internet on your computer yet, at least a program to connect to the Internet, for example the same wvdial program. So that you can connect, for example, my modem in the console. At least I figured it out. But what if you need it?
In order to get a list of Internet addresses where our deb packages are located, I use the program apt-get, in the form of a command apt-get --print-uris --yes Here --print-uris returns the URL to the screen. You don't need superuser rights to run this command, so sudo You don't need to enter.

apt-get --print-uris --yes install wvdial

But to filter out the results and leave only the URLs. I take advantage of opportunities grep together with cut, in order to filter out the results of the program output. Instead of wvdial you can enter the program you want to install.

apt-get --print-uris --yes install wvdial | grep ^\" | cut -d\" -f2

Now let's make the output to a file which we can then successfully feed to the program for downloading our deb packages. My request in the terminal began to look like this.

apt-get --print-uris --yes install wvdial | grep ^\" | cut -d\" -f2 > Loading.txt

Now in order to download all deb packages I will only need to use the program wget, I wrote about her. It will be enough to do

This is the file that was created when the command given above was executed. You can write the full path to this file if it is not in the folder where you opened the terminal.

You can also get a list of addresses needed to update the distribution.

apt-get --print-uris --yes dist-upgrade | grep ^\" | cut -d\" -f2 > "distribution updates"

wget -i "distribution updates"


When downloading a large number of files, you may need to select the folder into which the files will be downloaded and the command will look like this

wget --directory-prefix=/path/where/download/files -i Download.txt


wget --directory-prefix=/path/where/download/files -i "distribution updates"


Well, now all that remains is to transfer the downloaded deb packages to a computer without the Internet and install them. In my case, I downloaded the program wvdial, and he pulled out four deb packages as dependencies. We take these packages with a flash drive, transfer them to the computer for which we downloaded the files, and install them using the command.

Go to the directory with downloaded and transferred deb packages

cd /path/to/ our/deb packages


And install our packages.

sudo dpkg -i *deb


That's essentially it, the program wvdial installed. In a similar way, you can download absolutely any program in Linux Ubuntu, Kubuntu, Lubuntu for offline installation. Maybe in other distributions, I don’t know, I only tried these.

Often, installing programs on Linux systems, in particular on Ubuntu, occurs in the standard way: adding a repository, if necessary, importing a security key, updating data about the new repository and, directly, installing the application.

However, this method does not always take place, since not all applications are available in standard repositories or in ones you added, therefore, let's consider another option for installing applications using .deb packages. For example, the Chrome browser is most often installed in this way - a .deb package is downloaded from the official page, and when installed, the Google repository is automatically connected to the system for further program updates.

Let's look at an example of installing a .deb package using the Transcoder program as an example. On the Internet you found the Transcoder program, however, to install it, the manufacturer offers to download the .deb package. Well, let's do this. Select the system bit depth and download the file. In most cases, the developer has already made sure that the package is ready for installation; exception cases will not be considered in the article. Also, programs that do not have a ready-made .deb package and do not have their own repository can be found in third-party repositories.

So, the file has been downloaded. We find it in the Downloads folder and just run it. After this, the Ubuntu Application Center window will open in front of you, as in the figure below:

Click on the Install button and enter the superuser password. We wait for some time, watching the picture below:

Upon completion of all operations, the program will be installed on your system, and you can find it in the Dash menu.

There is also an alternative option for installing the deb package for users who prefer a terminal window.
Go to the folder with the downloaded file:

Cd ~/Downloads

(or cd ~/Downloads, depending on your system language)

and run the following command:

Sudo dpkg -i downloaded_file_name.deb

where downloaded_file_name is the name of your file. Enter the superuser password and wait for the installation to complete.

Most Ubuntu users install programs using the utility apt-get. Indeed, this method is very good and very simple. But many people find themselves at a dead end when they download a file from deb and they can't install it.

"Dependence apt-get- not a very good habit.

In this tip we will look at a way to install programs from files deb using the utility dpkg, included with Ubuntu Linux (and its derivatives, as well as Debian).

Step-by-step instruction:

Attention! Since the restriction on installing programs on the system is one of the main tenets of system security, install the program you received from the Internet in the form of a file deb, you will only succeed if you have superuser rights.

To install the .deb file, log in as root (or simply run the command sudo, then entering the correct password) and run the following command on the Ubuntu command line: dpkg -i file.deb where file.deb is the .deb file you want to install.

You may also find the following features of the utility useful in your work: dpkg: dpkg --unpack file.deb - unpacks the contents of the deb file, without installing it on the system

dpkg --configure file.deb - changing the settings of the installed package

dpkg --remove file.deb - remove file file.deb from the system

In general, this method is the most common when installing deb files. Don't be afraid to use what's comfortable!

If you're interested in learning about other dpkg features, you can get comprehensive help by running the command man dpkg.

Techniques for working in Ubuntu.
Chapter 6: Package Management

Original: "Ubuntu Hacks: Chapter 6 - Package Management"
Authors: Kyle Rankin, Jonathan Oxer, Bill Childers
Publication date: June 2006
Translation: N. Romodanov
Translation date: September 2010

Use command line capabilities to install individual .deb files when other automated tools cannot be used.

Package management in Debian-based distributions is very powerful and saves a lot of effort that could be wasted searching for the latest packages and keeping track of dependencies. Possibilities of automated tools such as apt-get, Synaptic and Adept are almost always enough for most users, and you should use them whenever possible. However, sometimes circumstances arise where you may need to install a package directly .deb.

Warning. Ubuntu uses automated package installation tools for good reason. With their help, special security measures are implemented to ensure package compatibility and the availability of libraries if packages need them. If you install individual files .deb(especially those that are not packaged for a specific version of Ubuntu), not only do you lose a lot of these benefits, you can also, due to library incompatibility, break parts of the system, overwrite files that other Ubuntu programs depend on, or add unique versions that will make it difficult to update your system while it is in use. Before installing a separate package .deb, especially if you are new to Ubuntu, please explore all other installation options, including using the universe and multiverse repositories [Tip #60]. You've created your own "Ubuntu style" kernel If you are using the utility make-kpkg compiled your own kernel from source, you should end up with a package .deb, which will contain the kernel binary code, and files .deb for any additional module you might build (the specific steps for this procedure are described in the section "Building Ubuntu-style kernels" [Hack #78]). You compiled your own package from Ubuntu sources As with compiling the kernel, you compiled the Ubuntu source code using the utility dpkg and eventually you got a separate file .deb, which you need to install manually. Do you want to return to the old version of the program? This situation may arise, in particular, if you are using the developer release of Ubuntu. Sometimes the latest versions of developer releases have bugs. In this case, you may need to revert to a previous version of the package. One of the easiest ways to do this is to find an older version of the package .deb(perhaps in your local package cache in /var/cache/apt/archives/) and installing it manually. The program you want to install has a .deb extension, but it is not in the Ubuntu repositories There may be circumstances in which a package is missing from the Ubuntu repositories .deb, which you want to install because it is a newer package than what Ubuntu offers, since you found a more generic version of the file .deb, or a third party provided the file .deb for Ubuntu, but has not yet created its own package repository (for example, like the Opera Web browser in its current package version).

Clue

If you find a program packaged in .deb format, then nine times out of ten there is a good chance that this program is already in one of the Ubuntu repositories. For details about additional repositories that are provided by Ubuntu and third parties, see the section "Changing the list of package repositories" [Tip #60].

The program you installed or updated was not completely installed because there is another installed package that contains the same files In relatively rare cases, we have encountered situations where two packages use the same files and when one of them is updated, an error message appears indicating that an attempt is being made to overwrite files from the other package. In these cases, you need to use the utility dpkg manually install this package using the --force option.

Installing the .deb file

Whenever you, regardless of the reason, need to install a file .de b, you need to contact the utility dpkg. Utility dpkg is a tool that, on Debian-based distributions, is used to install files .deb. (Even when you use automatic package management tools, behind the scenes the system actually uses dpkg). If you are familiar with the tool rpm used in distributions based on RPM packages, you will find that dpkg similar syntax. To install a regular file from the command line .deb, type the following:

Whiprush@ubuntu:~$ sudo dpkg -i packagename.deb

Replace packagename.deb with the filename .deb, which you want to install. If you have multiple files that you want to install at the same time, you can list them one by one on the command line

Whiprush@ubuntu:~$ sudo dpkg -i package1.deb package2.deb package3.deb

or use the wildcard [Hack #13] to install all .deb files that are in the current directory:

Whiprush@ubuntu:~$ sudo dpkg -i *.deb

Utility dpkg also has a parameter that specifies recursive execution (-R). If you have a directory full of deb files, you can install them like this:

Whiprush@ubuntu:~$ sudo dpkg -i -R /path/to/directory

and utility dpkg will recursively search and install all files .deb, which are located in this directory and all its subdirectories.

Sometimes when you install a package using the utility dpkg, the installation may fail due to the package being marked as hold because it conflicts with another package, or it depends on other packages that are not installed, or the installation of a package attempts to overwrite files related to another package, or for a variety of other reasons. IN dpkg There are a number of --force options you can use to ignore these problems and continue installing the package.

Warning

The --force options are only for experts who are familiar with the package system .deb and with dependencies existing within the system. Generally, package installations fail for serious reasons, and if you are a newbie and you are forced to install a package anyway, the installation will most likely end with a broken system for you. Therefore, use these options with caution.

To see the full list of --force options, type the following:

Whiprush@ubuntu:~$ dpkg --force-help

Some of the most useful options include the following:

Installing a package even if it is marked as hold.

Force-overwrite

Installing a package even though it may overwrite files from another package.

Display a list of errors about missing dependencies and continue with the installation anyway.

Force-conflicts

Even if a package conflicts with another package, continue with the installation anyway.

So if you have a file .deb, which needs to be installed and which overwrites files from another package, and you have checked everything and decided that everything will be fine, then in order to continue, enter:

Whiprush@ubuntu:~$ sudo dpkg -i --force-overwrite packagename.deb

Removing a package

Sometimes you may need to remove an individual package manually. IN dpkg There are -r and -P options to remove a package and remove a package while clearing configuration files, respectively. To remove a package, enter:

Whiprush@ubuntu:~$ sudo dpkg -r packagename

Please note that you are not specifying the extension .deb in the name of the file that you may have previously installed, there is only the name of the package itself. When the -r option is specified, dpkg will search and delete all files of this package, except for configuration files, which will be left in case the program is installed again. If you want to clear the system of all files, including configuration files, use the -P option:

Whiprush@ubuntu:~$ sudo dpkg -P packagename