이 문서에서는 RedHat에서 개발한 Yellowdog Updater Modified (YUM) 도구를 사용하여 Linux 시스템에서 패키지를 설치, 업데이트, 제거, 찾기, 패키지 및 저장소를 관리하는 방법에 대해 배우게 될 것입니다.
이 문서에서 표시된 예제 명령은 실제로 RHEL 8 서버에서 테스트되었으며, 학습 목적으로 이러한 자료를 사용하거나 RHEL 인증을 위해 사용하거나 새로운 패키지를 설치하고 시스템을 최신 상태로 유지하는 방법을 탐색할 수 있습니다.
이 문서의 기본 요구 사항은 명령어에 대한 기본적인 이해와 작동하는 Linux 운영 체제가 있어야 하며, 아래 나열된 모든 명령어를 탐색하고 연습할 수 있는 환경이어야 합니다.
YUM이란 무엇인가요?
YUM (Yellowdog Updater Modified)은 오픈 소스 명령 줄 및 그래픽 기반 패키지 관리 도구로 RPM (RedHat Package Manager) 기반 Linux 시스템용입니다.
사용자 및 시스템 관리자가 시스템에서 소프트웨어 패키지를 쉽게 설치, 업데이트, 제거 또는 검색할 수 있도록 합니다. 이것은 오픈 소스로 GPL (일반 공중 사용 허가서) 아래에서 개발되고 출시되었으며 이는 누구나 버그를 수정하고 사용자 정의 패키지를 개발하기 위해 코드를 다운로드하고 액세스할 수 있는 것을 의미합니다.
YUM은 종속성 문제를 해결하여 패키지를 자동으로 설치하기 위해 다양한 서드 파티 저장소를 사용합니다.
업데이트: yum 명령어가 dnf 명령어로 대체되었습니다. 이는 yum의 차세대 버전으로서 최신 RPM 기반 배포판에서 YUM의 대체품으로 간주됩니다.
1. YUM으로 패키지 설치
# yum install firefox Loaded plugins: fastestmirror Dependencies Resolved ================================================================================================ Package Arch Version Repository Size ================================================================================================ Updating: firefox i686 10.0.6-1.el6.centos updates 20 M Updating for dependencies: xulrunner i686 10.0.6-1.el6.centos updates 12 M Transaction Summary ================================================================================================ Install 0 Package(s) Upgrade 2 Package(s) Total download size: 32 M Is this ok [y/N]: y Downloading Packages: (1/2): firefox-10.0.6-1.el6.centos.i686.rpm | 20 MB 01:10 (2/2): xulrunner-10.0.6-1.el6.centos.i686.rpm | 12 MB 00:52 ------------------------------------------------------------------------------------------------ Total 63 kB/s | 32 MB 02:04 Updated: firefox.i686 0:10.0.6-1.el6.centos Dependency Updated: xulrunner.i686 0:10.0.6-1.el6.centos Complete!
위의 명령어는 Firefox에 필요한 모든 종속성을 자동으로 찾아 설치하기 위해 아래 명령어를 실행하기만 하면 됩니다.
# yum -y install firefox
2. YUM으로 패키지 제거하기
모든 종속성과 함께 패키지를 완전히 제거하려면 아래와 같이 다음 명령을 실행하세요.
# yum remove firefox Loaded plugins: fastestmirror Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package firefox.i686 0:10.0.6-1.el6.centos set to be erased --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================== Package Arch Version Repository Size ==================================================================================================== Removing: firefox i686 10.0.6-1.el6.centos @updates 23 M Transaction Summary ==================================================================================================== Remove 1 Package(s) Reinstall 0 Package(s) Downgrade 0 Package(s) Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : firefox-10.0.6-1.el6.centos.i686 1/1 Removed: firefox.i686 0:10.0.6-1.el6.centos Complete!
마찬가지로, 위의 명령은 패키지를 제거하기 전에 확인을 요청합니다. 확인 프롬프트를 비활성화하려면 아래와 같이 -y
옵션을 추가하세요.
# yum -y remove firefox
3. YUM으로 패키지 업데이트하기
예를 들어 MySQL 패키지의 오래된 버전이 있고 최신 안정적인 버전으로 업데이트하려면 다음 명령을 실행하면 종속성 문제를 자동으로 해결하고 설치합니다.
# yum update mysql Loaded plugins: fastestmirror Dependencies Resolved ============================================================================================================ Package Arch Version Repository Size ============================================================================================================ Updating: vsftpd i386 2.0.5-24.el5_8.1 updates 144 k Transaction Summary ============================================================================================================ Install 0 Package(s) Upgrade 1 Package(s) Total size: 144 k Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Updating : vsftpd 1/2 Cleanup : vsftpd 2/2 Updated: vsftpd.i386 0:2.0.5-24.el5_8.1 Complete!
4. YUM으로 패키지 목록 보기
list 기능을 사용하여 이름으로 특정 패키지를 검색하세요. 예를 들어 OpenSSH라는 패키지를 검색하려면 다음 명령을 사용하세요.
# yum list openssh Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.neu.edu.cn * epel: mirror.neu.edu.cn * extras: mirror.neu.edu.cn * rpmforge: mirror.nl.leaseweb.net * updates: mirror.nus.edu.sg Installed Packages openssh.i386 4.3p2-72.el5_6.3 installed Available Packages 4.3p2-82.el5 base
더 정확한 검색을 위해 알고 있다면 버전과 함께 패키지 이름을 정의하세요. 패키지의 특정 버전 OpenSSH-4.3p2를 검색하려면 다음 명령을 사용하세요.
# yum list openssh-4.3p2
[ 참고로: OpenSSH 서버 보안 강화 방법 ]
5. YUM으로 패키지 검색하기
만약 패키지의 정확한 이름을 기억하지 못한다면, 검색 기능을 사용하여 지정한 이름과 일치하는 모든 사용 가능한 패키지를 검색하십시오. 예를 들어, 단어와 일치하는 모든 패키지를 검색하려면.
# yum search vsftpd Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.neu.edu.cn * epel: mirror.neu.edu.cn * extras: mirror.neu.edu.cn * rpmforge: mirror.nl.leaseweb.net * updates: ftp.iitm.ac.in ============================== Matched: vsftpd ======================== ccze.i386 : A robust log colorizer pure-ftpd-selinux.i386 : SELinux support for Pure-FTPD vsftpd.i386 : vsftpd - Very Secure Ftp Daemon
6. YUM을 사용하여 패키지에 대한 정보 가져오기
설치하기 전에 패키지에 대한 정보를 알고 싶다면 다음 명령을 실행하십시오.
# yum info firefox Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.neu.edu.cn * epel: mirror.neu.edu.cn * extras: mirror.neu.edu.cn * rpmforge: mirror.nl.leaseweb.net * updates: ftp.iitm.ac.in Available Packages Name : firefox Arch : i386 Version : 10.0.6 Release : 1.el5.centos Size : 20 M Repo : updates Summary : Mozilla Firefox Web browser URL : http://www.mozilla.org/projects/firefox/ License : MPLv1.1 or GPLv2+ or LGPLv2+ Description: Mozilla Firefox is an open-source web browser, designed for standards : compliance, performance and portability.
7. YUM을 사용하여 모든 사용 가능한 패키지 목록
Yum 데이터베이스의 모든 사용 가능한 패키지 목록을 나열하려면 다음 명령을 사용하십시오.
# yum list | less
8. YUM을 사용하여 모든 설치된 패키지 목록
시스템의 모든 설치된 패키지 목록을 표시하려면 다음 명령을 실행하십시오.
# yum list installed | less
9. Yum 제공 기능
Yum 제공 기능은 특정 파일이 어떤 패키지에 속하는지 찾는 데 사용됩니다. 예를 들어, /etc/httpd/conf/httpd.conf가 있는 패키지의 이름을 알고 싶다면.
# yum provides /etc/httpd/conf/httpd.conf Loaded plugins: fastestmirror httpd-2.2.3-63.el5.centos.i386 : Apache HTTP Server Repo : base Matched from: Filename : /etc/httpd/conf/httpd.conf httpd-2.2.3-63.el5.centos.1.i386 : Apache HTTP Server Repo : updates Matched from: Filename : /etc/httpd/conf/httpd.conf httpd-2.2.3-65.el5.centos.i386 : Apache HTTP Server Repo : updates Matched from: Filename : /etc/httpd/conf/httpd.conf httpd-2.2.3-53.el5.centos.1.i386 : Apache HTTP Server Repo : installed Matched from: Other : Provides-match: /etc/httpd/conf/httpd.conf
10. Yum을 사용하여 사용 가능한 업데이트 확인
시스템에 설치된 패키지 중 몇 개가 업데이트가 가능한지 확인하려면 다음 명령을 사용하십시오.
# yum check-update
11. YUM을 사용하여 시스템 업데이트
시스템에 최신 보안 및 바이너리 패키지 업데이트를 적용하여 시스템을 최신 상태로 유지하려면 다음 명령을 실행하십시오.
# yum update
12. 모든 사용 가능한 그룹 패키지 목록
Linux에서는 여러 패키지가 특정 그룹에 묶여 있습니다. yum을 사용하여 개별 패키지를 설치하는 대신, 그룹에属하는 모든 관련 패키지를 함께 설치할 수 있는 특정 그룹을 설치할 수 있습니다. 예를 들어, 모든 사용 가능한 그룹을 나열하려면 다음 명령을 실행하십시오.
# yum grouplist Installed Groups: Administration Tools DNS Name Server Dialup Networking Support Editors Engineering and Scientific FTP Server Graphics Java Development Legacy Network Server Available Groups: Authoring and Publishing Base Beagle Cluster Storage Clustering Development Libraries Development Tools Eclipse Educational Software KDE (K Desktop Environment) KDE Software Development
13. 그룹 패키지 설치
특정 패키지 그룹을 설치하려면 groupinstall 옵션을 사용합니다. 예를 들어, “MySQL Database”를 설치하려면 다음 명령을 실행하십시오.
# yum groupinstall 'MySQL Database' Dependencies Resolved ================================================================================================= Package Arch Version Repository Size ================================================================================================= Updating: unixODBC i386 2.2.11-10.el5 base 290 k Installing for dependencies: unixODBC-libs i386 2.2.11-10.el5 base 551 k Transaction Summary ================================================================================================= Install 1 Package(s) Upgrade 1 Package(s) Total size: 841 k Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : unixODBC-libs 1/3 Updating : unixODBC 2/3 Cleanup : unixODBC 3/3 Dependency Installed: unixODBC-libs.i386 0:2.2.11-10.el5 Updated: unixODBC.i386 0:2.2.11-10.el5 Complete!
14. 그룹 패키지 업데이트
이미 설치된 그룹 패키지를 업데이트하려면, 아래와 같은 명령을 실행하십시오.
# yum groupupdate 'DNS Name Server' Dependencies Resolved ================================================================================================================ Package Arch Version Repository Size ================================================================================================================ Updating: bind i386 30:9.3.6-20.P1.el5_8.2 updates 981 k bind-chroot i386 30:9.3.6-20.P1.el5_8.2 updates 47 k Updating for dependencies: bind-libs i386 30:9.3.6-20.P1.el5_8.2 updates 864 k bind-utils i386 30:9.3.6-20.P1.el5_8.2 updates 174 k Transaction Summary ================================================================================================================ Install 0 Package(s) Upgrade 4 Package(s) Total size: 2.0 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Updating : bind-libs 1/8 Updating : bind 2/8 Updating : bind-chroot 3/8 Updating : bind-utils 4/8 Cleanup : bind 5/8 Cleanup : bind-chroot 6/8 Cleanup : bind-utils 7/8 Cleanup : bind-libs 8/8 Updated: bind.i386 30:9.3.6-20.P1.el5_8.2 bind-chroot.i386 30:9.3.6-20.P1.el5_8.2 Dependency Updated: bind-libs.i386 30:9.3.6-20.P1.el5_8.2 bind-utils.i386 30:9.3.6-20.P1.el5_8.2 Complete!
15. 그룹 패키지 제거
시스템에서 이미 설치된 그룹을 삭제하려면, 다음 명령을 사용하십시오.
# yum groupremove 'DNS Name Server' Dependencies Resolved =========================================================================================================== Package Arch Version Repository Size =========================================================================================================== Removing: bind i386 30:9.3.6-20.P1.el5_8.2 installed 2.1 M bind-chroot i386 30:9.3.6-20.P1.el5_8.2 installed 0.0 Transaction Summary =========================================================================================================== Remove 2 Package(s) Reinstall 0 Package(s) Downgrade 0 Package(s) Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Erasing : bind 1/2 warning: /etc/sysconfig/named saved as /etc/sysconfig/named.rpmsave Erasing : bind-chroot 2/2 Removed: bind.i386 30:9.3.6-20.P1.el5_8.2 bind-chroot.i386 30:9.3.6-20.P1.el5_8.2 Complete!
16. 활성화된 Yum 저장소 목록
시스템의 모든 활성화된 Yum 저장소를 보려면, 다음 옵션을 사용하십시오.
# yum repolist repo id repo name status base CentOS-5 - Base enabled: 2,725 epel Extra Packages for Enterprise Linux 5 - i386 enabled: 5,783 extras CentOS-5 - Extras enabled: 282 mod-pagespeed mod-pagespeed enabled: 1 rpmforge RHEL 5 - RPMforge.net - dag enabled: 11,290 updates CentOS-5 - Updates enabled: 743 repolist: 20,824
16. 활성화된 Yum 저장소 목록
다음 명령은 시스템의 활성화된 Yum 저장소를 모두 보여줄 것입니다.
# yum repolist all repo id repo name status C5.0-base CentOS-5.0 - Base disabled C5.0-centosplus CentOS-5.0 - Plus disabled C5.0-extras CentOS-5.0 - Extras disabled base CentOS-5 - Base enabled: 2,725 epel Extra Packages for Enterprise Linux 5 - i386 enabled: 5,783 extras CentOS-5 - Extras enabled: 282 repolist: 20,824
17. 특정 저장소에서 패키지 설치
특정 저장소에서 특정 패키지를 설치하려면, yum 명령에 --enablerepo
옵션을 사용해야 합니다. 예를 들어 PhpMyAdmin 패키지를 설치하려면, 다음 명령을 실행하십시오.
# yum --enablerepo=epel install phpmyadmin Dependencies Resolved ============================================================================================= Package Arch Version Repository Size ============================================================================================= Installing: phpMyAdmin noarch 3.5.1-1.el6 epel 4.2 M Transaction Summary ============================================================================================= Install 1 Package(s) Total download size: 4.2 M Installed size: 17 M Is this ok [y/N]: y Downloading Packages: phpMyAdmin-3.5.1-1.el6.noarch.rpm | 4.2 MB 00:25 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : phpMyAdmin-3.5.1-1.el6.noarch 1/1 Verifying : phpMyAdmin-3.5.1-1.el6.noarch 1/1 Installed: phpMyAdmin.noarch 0:3.5.1-1.el6 Complete!
18. 대화형 Yum 셸
Yum 유틸리티는 여러 명령을 실행할 수 있는 사용자 정의 셸을 제공합니다.
# yum shell Loaded plugins: fastestmirror Setting up Yum Shell > update httpd Loading mirror speeds from cached hostfile * base: mirrors.sin3.sg.voxel.net * epel: ftp.riken.jp * extras: mirrors.sin3.sg.voxel.net * updates: mirrors.sin3.sg.voxel.net Setting up Update Process >
19. Yum 캐시 정리
기본적으로 yum은 활성화된 저장소의 모든 패키지 데이터를 /var/cache/yum/ 디렉터리 및 하위 디렉터리에 보관합니다. 활성화된 저장소의 캐시 파일을 모두 삭제하려면 다음 명령을 정기적으로 실행하여 캐시를 정리하고 필요하지 않은 공간을 사용하지 않도록 해야 합니다. 아래 명령의 출력을 표시하지 않는 이유는 캐시 데이터를 그대로 유지하고자 하는 것입니다.
# yum clean all
20. Yum 이력 보기
yum 명령의 모든 과거 트랜잭션을 조회하려면 다음 명령을 사용하십시오.
# yum history Loaded plugins: fastestmirror ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 10 | root | 2012-08-11 15:19 | Install | 3 9 | root | 2012-08-11 15:11 | Install | 1 8 | root | 2012-08-11 15:10 | Erase | 1 EE 7 | root | 2012-08-10 17:44 | Install | 1 6 | root | 2012-08-10 12:19 | Install | 2 5 | root | 2012-08-10 12:14 | Install | 3 4 | root | 2012-08-10 12:12 | I, U | 13 E< 3 | root | 2012-08-09 13:01 | Install | 1 > 2 | root | 2012-08-08 20:13 | I, U | 292 EE 1 | System | 2012-08-08 17:15 | Install | 560 history list
Yum 명령의 기본 내용부터 고급 내용까지 그 예제와 함께 다루려고 노력했습니다. Yum 명령과 관련된 내용이 누락되었다면 댓글 상자를 통해 알려주세요. 받은 피드백을 바탕으로 해당 내용을 지속적으로 업데이트할 것입니다.
Source:
https://www.tecmint.com/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement/