![apt-get 进入下载模式](https://linux22.com/image/138375/apt-get%20%E8%BF%9B%E5%85%A5%E4%B8%8B%E8%BD%BD%E6%A8%A1%E5%BC%8F.png)
从man
页面apt-get
-d, --download-only
Download only; package files are only retrieved, not unpacked or installed. Configuration Item: APT::Get::Download-Only.
download
download will download the given binary package into the current directory.
那么以下命令有什么区别:
apt-get download apache2
apt-get install --download-only apache2
为什么第一个会出现以下错误:
Get:1 http://gr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 apache2 amd64 2.4.29-1ubuntu4.2 [95,1 kB]
Fetched 95,1 kB in 1s (102 kB/s)
W: Download is performed unsandboxed as root as file '/home/pkaramol/Desktop/apache2_2.4.29-1ubuntu4.2_amd64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
答案1
虽然我没能找出错误,但命令的差异似乎主要如下:
apt-get download apache2
将仅下载.deb
当前 wd 中的
所以下载后运行dpkg -i <filename>.deb
很可能会因为缺少依赖而失败
apt-get install --download-only apache2
将下载相应的.deb
和它的依赖项在/var/cache/apt/archives/
包缓存完成的位置下;