기타기술

Linux 패키지 파일 설치하지않고 다운로드만 받기

DongT 2025. 7. 17. 12:55
728x90
반응형


 

패키지를 수동으로 받아야 하는 경우가 종종 있음. 예를 들어 다른 서버에 수동 설치하거나, 네트워크가 차단된 환경 등에서 유용함.

1. 일반 설치 상태에서 다운로드-only 옵션 사용

sudo apt update
apt search nfs-common
sudo apt install --download-only nfs-common

하지만 이미 설치되어 있는 경우에는 다운로드만으로는 아무 동작도 하지 않음.

Reading package lists... Done
nfs-common is already the newest version (1:2.6.1-1ubuntu1.2).
0 upgraded, 0 newly installed, 0 to remove and 103 not upgraded.

2. 확인: 실제로 파일은 다운로드되지 않음

ls -l /var/cache/apt/archives/
dpkg -l | grep nfs-common

위 결과에서 `.deb` 파일이 존재하지 않음.

3. reinstall 명령으로 강제로 받아오기

설치되어 있어도 다시 받아오려면 다음과 같이 --reinstall 옵션을 줘야 함.

sudo apt install --download-only --reinstall nfs-common

그러면 `/var/cache/apt/archives/` 경로에 실제로 `.deb` 파일이 저장됨.

ls -l /var/cache/apt/archives/ | grep nfs-common
-rw-r--r-- 1 root root ... nfs-common_1%3a2.6.1-1ubuntu1.2_amd64.deb

4. 참고: dnf 또는 yum 사용하는 경우

RedHat 계열에서는 다음과 같이 `.rpm` 파일을 받아올 수 있음.

# dnf 명령 사용
dnf download nfs-utils

# yum 명령 사용
yum install --downloadonly --downloaddir=/tmp nfs-utils

※ dnf의 경우 dnf-plugins-core 패키지가 설치되어 있어야 함.

📝 마무리

패키지 파일을 따로 보관하거나 배포용으로 사용하는 경우 위와 같은 방식으로 수동 다운로드 가능함. 이미 설치된 패키지도 --reinstall 옵션을 활용하면 다시 받아올 수 있음.

 



 

728x90