How to Download All Repository Packages Using apt-get

aptpackage-managementrepository

Is there any way to just download all Ubuntu repositories using apt-get? I am looking for something like :

sudo apt-get install --download-only *

So that I can access the downloaded repository in the directory /var/cache/apt/archives/.

Best Answer

First of all, this is not a convenient way. Instead of this you should use the method mention here. But as an answer to the question.

  • First create a file which contains names of all the available packages using apt-cache.

    apt-cache  dumpavail |grep -oP "(?<=Package: ).*" >> packagelist
    

    This will create a file packagelist with all the available packages.

  • Now create a simple script to download all the packages present in the file packagelist

    #!/bin/bash
    for package in `cat packagelist`
     do
        apt-get install -y --download-only $package   
     done
    
  • Save it.

  • Make it executable using

    chmod +x your_script_name
    
  • Now open terminal and login as root

    sudo -i
    cd /folder/of/you/script
    ./you_script_name
    

It will download all the available package depending upon your /etc/apt/sources.list in /var/cache/apt/archives directory

Related Question