linux下载的安装包位置,及下载安装包到本地

以下以下载openssh软件为例

1.ubuntu系统

1).sudo apt install openssh 安装后,软件包默认缓存位置在/var/cache/apt/archives/下

2).只下载openssh包到本地且不安装
sudo apt download openssh
会下载到当前命令执行目录

3).执行下面命令下载openssh包及其依赖包到本地且不安装

sudo apt install -d openssh

会下载到/var/cache/apt/archives/目录下

2.redhat系统

1).yum命令默认不保存rpm包

修改/etc/yum.conf,在最后加入以下两行内容
[root@node03 ~]# vim /etc/yum.conf

cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1

修改完yum安装软件之后保存rpm包位置在/var/cache/yum/下

2).另外yum还可以一键下载openssh包及其依赖到本地不安装,比apt 分开下载openssh和openssh的依赖包两个命令方便一些

yum --downloadonly --downloaddir=./ install openssh

将openssh包及其依赖下载到当前目录,./表示当前目录

[root@localhost 桌面]# yum --downloadonly --downloaddir=./ install openssh
Last metadata expiration check: 1:10:02 ago on 20211223日 星期四 151911.
Package openssh-7.8.x86_64 is already installed.
Dependencies resolved.
================================================================================
 Package             Arch       Version                Repository          Size
================================================================================
Installing:
 openssh-server      x86_64      8.2                     redhat            335 k
Upgrading:
 openssh             x86_64      8.2                     redhat            252 k
Installing dependencies:
 openssh-clients     x86_64      8.2                     redhat            508 k

Transaction Summary
================================================================================
Install  2 Packages
Upgrade  1 Package

Total download size: 1.1 M
YUM will only download packages for the transaction.
Is this ok [y/N]: y
Downloading Packages:
(1/3): openssh-8.2.x86_64.rpm      479 kB/s | 252 kB     00:00    
(2/3): openssh-server-8.2.x86_64.r 539 kB/s | 335 kB     00:00    
(3/3): openssh-clients-8.2.x86_64. 617 kB/s | 508 kB     00:00    
--------------------------------------------------------------------------------
Total                                           1.3 MB/s | 1.1 MB     00:00     
Complete!
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'yum clean packages'.

下载之后出现在当前目录

linux下载的安装包位置,及下载安装包到本地_第1张图片

你可能感兴趣的:(linux,服务器,ubuntu,redhat,yum)