43

I have apt-get 0.7.23.1 on host machine. I do not have root, thus not able to update it, or install other packages.

I want to download .deb packages with it, but neither

apt-get -d bash

(Invalid operation bash)

nor

apt-get -d install bash

(do not have root)

work.

On my home machine with a newer version of apt-get I can

apt-get download bash

and it does exactly what I want it to.

How can I perform the same on the host machine?

Zanna
  • 70,465
disfated
  • 1,083

3 Answers3

37

The command apt-get download wasn't added until version 0.8.11 of apt. It was first available in Ubuntu 11.04 (which uses apt 0.8.13.2). I'm not sure what you're running as AFAICT no supported version of Ubuntu contains version 0.7.23.1 of apt. You should really have the system administrator upgrade the machine. (I know, not very helpful.)

It's not clear from your question whether or not you have access to a graphical environment. If you do, your best bet would be to grab the files from http://packages.ubuntu.com/

This is also possible from the command line as there are predictable urls. For instance:

wget http://archive.ubuntu.com/ubuntu/pool/main/a/apt/apt_0.7.25.3ubuntu9.4_i386.deb

You can find the correct version and whether the package is in main or universe by using apt-cache policy.

This is of course scriptable. Here's a quick one:

#! /bin/bash
PACKAGE=$1
URI=`apt-cache show $PACKAGE | grep "Filename:" | cut -f 2 -d " "`
wget http://archive.ubuntu.com/ubuntu/$URI
David Foerster
  • 36,264
  • 56
  • 94
  • 147
  • i don't have gui and of course i know that i can download packages manualy. – disfated Jun 09 '11 at 17:57
  • ok, there is an option --print uris, but it works fine only with download action. There is also a filename field in apt-cache show pkg, which i could wget, but it is absent in the older version... – disfated Jun 09 '11 at 18:02
  • I'm not sure what you're asking for then. You are aware that the feature you want isn't available in the version of apt that you have, you can't install new packages (so any non-default application is out of the question), and you don't want to use wget. I added a quick script that find the correct url and pass it to wget. Beyond that I'm out of ideas. – andrewsomething Jun 09 '11 at 18:21
  • @disfated I assume the system you're working on (the one local to you) has a GUI. Why not find the links locally (from packages.ubuntu.com) and paste the URLs over SSH (for wget)? – Oli Jun 09 '11 at 22:17
  • @andrewsomething oh, there is a "Filename" field in my apt-cache - at first i didn't notice it. it's ok now - i have uri and have wget installed. thank you and all responders :) – disfated Jun 10 '11 at 07:41
  • @Oli, i don't like the idea of doing what the computer can do - this is kind of challange and there likely will be much reusage in future – disfated Jun 10 '11 at 08:00
18

apt-get download [package] works without root privileges but only for Ubuntu Natty and newer. You can also use apt download [package].

If you've got aptitude installed, you can run use aptitude download [package]

RobinJ
  • 8,910
  • Do not have aptitude installed – disfated Jun 09 '11 at 16:19
  • 1
    apt is a Java tool. - I edited your answer because you were almost there. I tested apt-get download banshee as a normal user and it works just fine (downloads the package to the current path). – Oli Jun 09 '11 at 16:27
  • Ah. I've reverted the edit because I've just found out that version 0.7.23 of apt-get doesn't have a download function. – Oli Jun 09 '11 at 16:31
  • @Oli man apt gives me a manual of a java application ,indeed (strange). However, if you type apt in a terminal, you'll notice that it's about the same thing as aptitude and apt-get. – RobinJ Jun 09 '11 at 16:44
1

If there are many variants, then download all

 #! /bin/bash

 PACKAGE=$1
 apt-cache show $PACKAGE | grep "Filename:" | while read -r line; do URI=`echo "${line}" | cut -f 2 -d " "`; wget "http://archive.ubuntu.com/ubuntu/$URI"; done
guest
  • 11