How to install package file in linux

How to install a deb file, by dpkg -i or by apt?

I have a deb package for installation. Shall I install by dpkg -i my.deb , or by apt? Will both handle the software dependency problem well? If by apt, how can I install from the deb by apt?

I recommend not to directly use dpkg . In case of single deb, go with gdebi and in case of multiple debs, go for APT local repository.

@Tim gdebi identifies missing dependencies, can download & install (using apt),can install & configure (using dpkg).

9 Answers 9

When you use apt to install a package, under the hood it uses dpkg . When you install a package using apt, it first creates a list of all the dependencies and downloads it from the repository.

Once the download is finished it calls dpkg to install all those files, satisfying all the dependencies.

So if you have a .deb file, you can install it by:

sudo dpkg -i /path/to/deb/file sudo apt-get install -f 
sudo apt install /path/to/package/name.deb 

Note: APT maintains the package index which is a database ( /var/cache/apt/*.bin ) of available packages available in repo defined in /etc/apt/sources.list file and in the /etc/apt/sources.list.d directory. All these methods will fail to satisfy the software dependency if the dependencies required by the deb is not present in the package index.

Why use sudo apt-get install -f after sudo dpkg -i /path/to/deb/file (as mentioned in method 1)?

 -f, --fix-broken Fix; attempt to correct a system with broken dependencies in place. 

When dpkg installs a package and a package dependency is not satisfied, it leaves the package in an «unconfigured» state and that package is considered broken.

The sudo apt-get install -f command tries to fix this broken package by installing the missing dependency.

@Tim, apt-get is designed to install packages from repository. It maintains packages list as well as their respective repository address. So just moving a .dev file, which is not present in the apt package list, in /var/cache/apt/archives directory will not work. Because whenever you try to install this package using apt-get, it searches for its repository, which is not present. For this you have to create local repository which I think is useless.

@g_p thank you! im a little confused in your answer above. you write: «(it will work if the .deb package is present in the apt package list)» — I do not understand what is meant here. How can one ensure that the .deb package is present in the apt package list?

@BKSpurgeon, I have added bit information in my answer. To find-out if a package is present in the index or not run apt-cache search . You can also use apt-cache policy , which will give some additional information as well.

Читайте также:  Tableau desktop for linux

Modern apt-get can be uset to install a package simply with apt-get install /path/to/package/name.deb . It would be neat if the author of this answer decided to integrate that. If not, I’ll go add that answer sometime when I have enough rep here

Install your foo.deb file with dpkg -i foo.deb . If there are some errors with unresolved dependencies, run apt-get install -f afterwards.

I got Unable to locate package trying this way and got puzzled. I used as in Windows just name of package after switching to archive folder. Should be ./ for Unix if in current folder or full path. That is if deb is not in folder present in PATH .

For scripting, use apt update && dpkg -i foo.deb || apt install -f -y to make sure that foo.deb is not removed by apt install -y .

You can install a local .deb package by:

Make sure to specify a local relative or absolute path ( ./ if in current dir), otherwise it will look for foo.deb in the remote repos and fail.

Here’s the best way to install a .deb file on Ubuntu on the command-line:

If you don’t have gdebi installed already, install it using sudo apt install gdebi-core .

Why gdebi?

gdebi will look for all the dependencies of the .deb file, and will install them before attempting to install the .deb file. I find this much preferable than sudo dpkg -i skype.deb && sudo apt install -f . The latter is much too eager to remove dependencies in certain situations. For instance, when I tried to install Skype, it attempted to remove 96 (!) packages, including packages like compiz and unity ! gdebi gave a much clearer error message:

 $ sudo gdebi skype.deb Cannot install 'libqtgui:i386' 

worked great thx! btw, could be that the attempt to remove were about that transitional/temporary packages? or you think it would really break the system?

Dude I ran into an issue with your solution. I was trying to install Rstudio. It automatically found an old version of R for me. While using the solution by @g_p I was able to install Rstudio only.

Check the dependencies with dpkg -I my.deb and apt-get install the dependencies before dpkg -i my.deb .

May be you can copy the my.deb in /var/cache/apt/archives and install it directly with apt-get but I never tried. Doesn’t work, apt-get and dpkg are looking for packages listed in archives.

Thanks. in your first sentenct, do you mean apt-get install my.deb by apt-get install ? Is it to install from the deb file? Why do we need dpkg -i my.deb after that?

I always installed local .deb s with dpkg -i , my understanding is that apt doesn’t have an option to install them, apart the directory in /var/cache/. where are downloaded (I may be wrong)

It seems that apt-get install ./my.deb will do something, because it outputs a lot of things. What does it do?

The simplest answer would be to use dpkg by running dpkg -i packagename.deb . You could then uninstall it by running dpkg -r packagename.deb .
apt-get is a higher level installer based off of dpkg, and as such you could apt-get install packagename.deb .
It would be beneficial for add it to your apt-get archives directory ( /var/cache/apt/archives ) so you could reference it as a package with dependencies and not a standalone .deb archive.
Also, by adding it to your apt-get archives directory, you have the opportunity to use dependencies with apt-get install packagename . This would let you install it with any manually added dependencies instead of dpkg’s standalone archive-based system.

Читайте также:  Настройка фаервола в линуксе

Note: if you want to use apt-get install with a local package file, you must install it in /var/cache/apt/archives , otherwise apt-get may decide to download it anyway.

Modern apt-get can be used to install a package simply with apt-get install /path/to/package/name.deb .

(should be done as edit to the top answer but it was rejected — see https://unix.stackexchange.com/posts/159114/edit)

The shortest way to install a local package with all required dependencies that worked for me:

sudo apt --fix-broken install ./name.deb 

It is —fix-broken option that makes dependencies to be installed.

Источник

How to Install an RPM File On Linux OS (CentOS, RHEL, & Fedora)

While working in Linux, you may have seen downloadable files with the .rpm extension. Rpm files are designed to be downloaded and installed independently, outside of a software repository.

This guide will show you how to install a .rpm file to your Linux CentOS or Fedora system.

how to install rpm file on linux

Note: RPM Package Manager (RPM) is a free and open-source package management system for installing, uninstalling and managing software packages in Linux.

  • A user account with sudo privileges
  • Access to a terminal window / command line (Menu > applications > utilities > terminal, Ctrl-Alt-F2)
  • RPM, DNF, & YUM Package Managers (all included by default)

Step 1: Download RPM Installation File

Typically, a web browser is used to locate and download a .rpm file. However, if a browser is not available you can still download a file if you know where it’s located.

You may need to install a software tool called wget .

To install wget in CentOS, enter the following in a terminal window:

To install wget in Fedora, enter the following:

Now, you can use the wget command to download the .rpm file you want. Enter the following:

wget http://some_website/sample_file.rpm

The system should reach out to the website and download the file to your current working directory.

Note: You can look up the address of a particular .rpm file in a web browser on another system. Also, this is a handy way to install more recent software versions or special non-standard software. Also, take care when installing software packages! Make sure you trust the source before you install. Usually, a developer will include a verification method to make sure you’re getting authentic software.

Step 2: Install RPM File on Linux

Install RPM File Using RPM Command

To install a .rpm package in CentOS Linux, enter the following:

sudo rpm -i sample_file.rpm

The -i switch tells the package manager you want to install the file.

More information on the RPM installer can be found in the RPM documentation.

Читайте также:  Файловый сервер linux mint

Install RPM File with Yum

Alternately, you can use the yum package manager to install .rpm files.

sudo yum localinstall sample_file.rpm

The localinstall option instructions yum to look at your current working directory for the installation file.

Note: YUM stands for Yellowdog Updater Modified. Normally, yum looks to your enabled software repositories for new software packages to install. More recent verbiage suggests using install instead of localinstall, but it’s up to you.

Install RPM on Fedora

To install an .rpm package on Fedora Linux, enter the following:

sudo rpm -i sample_file.rpm

Just as in CentOS, the -i switch tells RPM to install the software.

Another method is to use the dnf utility to install the package:

sudo dnf localinstall sample_file.rpm

Unlike many Linux tools, DNF is not a set of initials. It is merely the next evolution of the yum package manager.

Remove RPM Package

The RPM installer can be used to remove (or uninstall) a software package.

Enter the following into a terminal window:

sudo rpm -e sample_file.rpm

The -e option instructs RPM to erase the software. Check RPM Dependencies

So far, this guide assumes the software either doesn’t have dependencies or already has them installed.

To check the .rpm file for dependencies using the following command:

sudo rpm -qpR sample_file.rpm

The system should list all the dependencies:

  • -q – This option tells RPM to query the file
  • -p – This option lets you specify the target package to query
  • -R – This lists the requirements for the package

If there are any missing dependencies, you can install them from the standard repositories using yum or dnf. If your software requires other non-standard software, it will often be noted in the installation instructions.

Download RPM Packages from the Repository

One exciting feature of the yum package manager is that it allows you to download .rpm files directly from the repository. This might be helpful if you have limited bandwidth, or want to copy a single downloaded file between systems. It could also help if you have intermittent internet access, and you don’t want to spend time waiting for your installer to finish.

To download a .rpm file from the repositories, enter the following:

sudo yumdownloader packagename

If you wanted to download the files for Apache, for instance, you’d replace packagename with httpd. You can then install the file as above.

Note: In Linux, administrators find it helpful to have a single tool to manage software. That tool – called a package manager – can install software, keep track of software requirements, and track updates and patches. Package managers also work with repositories, which are secure and standardized libraries of commonly-used and well-supported applications. If you had to install wget in Step 1, that’s an example of installing from a repository.

In this tutorial, we covered three different options for installing RPM files on Linux.

As with most Linux software, your default package manager makes it simple to track installations, updates, and prerequisites.

Источник

Оцените статью
Adblock
detector