This question already has an answer here:

I thought when I executed apt install pkg, a deb file would be downloaded and put into /var/cache/apt/archives. But today after executing apt install python2.7 python-pip, I can't find any deb file in var/cache/apt/archives. I don't know why. Is it because I write sudo apt install pkg into a bash script and didn't execute the script with sudo?

For some reason, I need to be able to install some package from deb files, meaning that I should be able to execute dpkg -i pkg.deb, instead of apt install pkg to do the installation.

I've tried the command apt download pkg and it did download a deb file but it is a tiny file. When I execute dpkg -i pkg.deb, there are many errors about dependencies and I have to execute apt install -f to solve them.

My system has a working internet connection. How can I get a complete .deb package?

marked as duplicate by muru, Braiam, user68186, waltinator, Fabby Apr 10 '18 at 7:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Deb packages have dependencies on other deb packages, which is why apt exists. You can list the dependencies of a deb with apt-cache depends <program_name> if you must install via dpkg. – dsstorefile1 Apr 9 '18 at 7:46
  • “Is it because I write sudo apt install pkg into a bash script and didn't execute the script with sudo?” This depends on whether you entered the password or configured your OS to not require the password for the script. Anyway, have you captured the output of the script? – Melebius Apr 9 '18 at 7:53
  • @Melebius The output looks like normal. It asks me to type password when I execute it. After typing the password, all of sudo apt install in the script will be executed without any error. – Yves Apr 9 '18 at 8:03
  • For the first paragraph, see askubuntu.com/questions/794983/…, for the rest of the question, you'd be better off with a solution from askubuntu.com/questions/974/… – muru Apr 9 '18 at 9:33
  • Possible duplicate of How do I install a .deb file via the command line? – David Foerster Oct 9 '18 at 10:11

You need to run a command that automatically resolves all the .deb file's dependencies and installs the .deb file and its missing dependencies with the same command. You will need a working internet connection and your installed software to be updated with sudo apt update && sudo apt upgrade to download any missing dependencies. Open the terminal, change directories using cd to the directory containing package-name.deb, and type:

sudo apt-get install ./package-name.deb

where package-name.deb should be replaced by the name of the .deb file that you are trying to install.

Not the answer you're looking for? Browse other questions tagged or ask your own question.