apt-get仅下载不安装软件包
转自:https://blog.csdn.net/qq_14910065/article/details/127011650
apt-get -d download xxx #xxx是待下载的安装包
ubuntu下载软件安装包命令。仅仅下载deb格式的安装包,不安装。
/var/cache/apt/archives #下载后的安装包在此路径下
第一种方法:
root@VM-4-11-ubuntu:/var/cache/apt/archives# apt -d download nginx
Get:1 http://mirrors.tencentyun.com/ubuntu bionic-security/main amd64 nginx all 1.14.0-0ubuntu1.10 [3,596 B]
Fetched 3,596 B in 0s (0 B/s)
W: Download is performed unsandboxed as root as file '/var/cache/apt/archives/nginx_1.14.0-0ubuntu1.10_all.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
root@VM-4-11-ubuntu:/var/cache/apt/archives# ll
total 36
drwxr-xr-x 3 root root 24576 Sep 23 15:21 ./
drwxr-xr-x 3 root root 4096 Sep 23 15:16 ../
-rw-r----- 1 root root 0 Jul 25 2018 lock
-rw-r--r-- 1 root root 3596 Apr 12 22:28 nginx_1.14.0-0ubuntu1.10_all.deb
drwx------ 2 _apt root 4096 Sep 23 15:16 partial/
第二种方法(好使):
sudo apt-get -d install xxx #xxx是待下载的安装包
ubuntu下载软件安装包命令。仅仅下载deb格式的安装包,不安装。
/var/cache/apt/archives #下载后的安装包在此路径下
root@VM-4-11-ubuntu:/var/cache/apt/archives# sudo apt-get -d install lrzsz #这里下载的是上传和下载的这个安装包 Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: minicom The following NEW packages will be installed: lrzsz 0 upgraded, 1 newly installed, 0 to remove and 138 not upgraded. Need to get 74.8 kB of archives. After this operation, 531 kB of additional disk space will be used. Get:1 http://mirrors.tencentyun.com/ubuntu bionic-security/universe amd64 lrzsz amd64 0.12.21-10~build0.18.04.1 [74.8 kB] Fetched 74.8 kB in 0s (4,789 kB/s) Download complete and in download only mode
查看
root@VM-4-11-ubuntu:/var/cache/apt/archives# ll total 112 drwxr-xr-x 3 root root 24576 Sep 23 15:24 ./ drwxr-xr-x 3 root root 4096 Sep 23 15:24 ../ -rw-r----- 1 root root 0 Jul 25 2018 lock -rw-r--r-- 1 root root 74772 Jan 30 2019 lrzsz_0.12.21-10~build0.18.04.1_amd64.deb -rw-r--r-- 1 root root 3596 Apr 12 22:28 nginx_1.14.0-0ubuntu1.10_all.deb drwx------ 2 _apt root 4096 Sep 23 15:24 partial/
root@VM-4-11-ubuntu:/var/cache/apt/archives#
通过两种方法最后都下载了需要的安装包
root@VM-4-11-ubuntu:/var/cache/apt/archives# clear root@VM-4-11-ubuntu:/var/cache/apt/archives# ls lock lrzsz_0.12.21-10~build0.18.04.1_amd64.deb nginx_1.14.0-0ubuntu1.10_all.deb partial root@VM-4-11-ubuntu:/var/cache/apt/archives# pwd /var/cache/apt/archives root@VM-4-11-ubuntu:/var/cache/apt/archives#