CentOS & RedHat Linux menggunakan yum
sebagai perintah untuk mengatur instalasi paket (package management tool). Saya baru tahu dari Wikipedia kalau yum
itu sendiri adalah singkatan dari “Yellowdog Updater, Modified”. Sintaks pemakaiannya mirip dengan apt-get
-nya Debian/Ubuntu Linux. Misalnya untuk menginstal paket dari repositori, saya bisa menggunakan perintah yum install
, Misalnya saya ingin memasang paket Apache web server (httpd
) :
[root@web01 ~]# yum install httpd Loaded plugins: fastestmirror Determining fastest mirrors CDROM | 4.0 kB 00:00 ... CDROM/primary_db | 4.4 MB 00:00 ... Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-29.el6.centos will be installed --> Processing Dependency: httpd-tools = 2.2.15-29.el6.centos for package: httpd-2.2.15-29.el6.centos.x86_64 --> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-29.el6.centos.x86_64 --> Processing Dependency: /etc/mime.types for package: httpd-2.2.15-29.el6.centos.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-29.el6.centos.x86_64 --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-29.el6.centos.x86_64 --> Running transaction check ---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed ---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed ---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed ---> Package httpd-tools.x86_64 0:2.2.15-29.el6.centos will be installed ---> Package mailcap.noarch 0:2.1.31-2.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================================================================================== Package Arch Version Repository Size ==================================================================================================================================================================== Installing: httpd x86_64 2.2.15-29.el6.centos CDROM 821 k Installing for dependencies: apr x86_64 1.3.9-5.el6_2 CDROM 123 k apr-util x86_64 1.3.9-3.el6_0.1 CDROM 87 k apr-util-ldap x86_64 1.3.9-3.el6_0.1 CDROM 15 k httpd-tools x86_64 2.2.15-29.el6.centos CDROM 73 k mailcap noarch 2.1.31-2.el6 CDROM 27 k Transaction Summary ==================================================================================================================================================================== Install 6 Package(s) Total download size: 1.1 M Installed size: 3.6 M Is this ok [y/N]: y Downloading Packages: -------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 27 MB/s | 1.1 MB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : apr-1.3.9-5.el6_2.x86_64 1/6 Installing : apr-util-1.3.9-3.el6_0.1.x86_64 2/6 Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 3/6 Installing : httpd-tools-2.2.15-29.el6.centos.x86_64 4/6 Installing : mailcap-2.1.31-2.el6.noarch 5/6 Installing : httpd-2.2.15-29.el6.centos.x86_64 6/6 Verifying : httpd-2.2.15-29.el6.centos.x86_64 1/6 Verifying : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 2/6 Verifying : httpd-tools-2.2.15-29.el6.centos.x86_64 3/6 Verifying : apr-1.3.9-5.el6_2.x86_64 4/6 Verifying : mailcap-2.1.31-2.el6.noarch 5/6 Verifying : apr-util-1.3.9-3.el6_0.1.x86_64 6/6 Installed: httpd.x86_64 0:2.2.15-29.el6.centos Dependency Installed: apr.x86_64 0:1.3.9-5.el6_2 apr-util.x86_64 0:1.3.9-3.el6_0.1 apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 httpd-tools.x86_64 0:2.2.15-29.el6.centos mailcap.noarch 0:2.1.31-2.el6 Complete! [root@web01 ~]#
Dari contoh di atas, terlihat bahwa yum
tidak hanya memasang paket httpd
, yum
juga memasang beberapa paket lain yang diperlukan oleh httpd
(dependencies packages). Dalam contoh tadi ada 5 paket tambahan yang ikut terpasang secara otomatis.
Nah lucunya saat saya ingin membuang paket httpd
, paket-paket lain tadi tidak ikut terbuang. Misalnya dengan yum remove
berikut ini :
[root@web01 ~]# yum install httpd Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile CDROM | 4.0 kB 00:00 ... Setting up Install Process Package httpd-2.2.15-29.el6.centos.x86_64 already installed and latest version Nothing to do [root@web01 ~]# vi /etc/yum.conf [root@web01 ~]# yum remove httpd Loaded plugins: fastestmirror Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-29.el6.centos will be erased --> Finished Dependency Resolution CDROM | 4.0 kB 00:00 ... Dependencies Resolved ============================================================================================================================================================================================================================================== Package Arch Version Repository Size ============================================================================================================================================================================================================================================== Removing: httpd x86_64 2.2.15-29.el6.centos @CDROM 2.9 M Transaction Summary ============================================================================================================================================================================================================================================== Remove 1 Package(s) Installed size: 2.9 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : httpd-2.2.15-29.el6.centos.x86_64 1/1 Verifying : httpd-2.2.15-29.el6.centos.x86_64 1/1 Removed: httpd.x86_64 0:2.2.15-29.el6.centos Complete! [root@web01 ~]#
yum
hanya membuang paket httpd
saja. Ada 5 paket lain yang tadi ikut terinstal tidak terbuang juga.
[root@web01 ~]# rpm -qa | egrep "apr|httpd|mailcap" apr-util-1.3.9-3.el6_0.1.x86_64 httpd-tools-2.2.15-29.el6.centos.x86_64 apr-1.3.9-5.el6_2.x86_64 apr-util-ldap-1.3.9-3.el6_0.1.x86_64 mailcap-2.1.31-2.el6.noarch [root@web01 ~]#
Di Debian, ada opsi untuk menggunakan apt-get autoremove
untuk menghapus sisa paket dependensi yang sudah tidak dipakai. Saya juga baru tahu ternyata ada opsi untuk mengatur yum
supaya menghapus semua paket dependensinya. Opsi ini perlu diaktifkan dulu di dalam berkas /etc/yum.conf
seperti ini :
[root@web01 ~]# echo "clean_requirements_on_remove=1" >> /etc/yum.conf
Opsi clean_requirements_on_remove
akan membuat yum
membersihkan setiap paket dependensinya. Setelah penambahan opsi tersebut, contohnya seperti berikut ini :
[root@web01 ~]# yum remove httpd Loaded plugins: fastestmirror Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-29.el6.centos will be erased --> Finished Dependency Resolution --> Finding unneeded leftover dependencies ---> Marking httpd-tools to be removed - no longer needed by httpd ---> Marking apr-util-ldap to be removed - no longer needed by httpd ---> Marking mailcap to be removed - no longer needed by httpd ---> Marking apr-util to be removed - no longer needed by httpd-tools ---> Marking apr to be removed - no longer needed by httpd-tools Found and removing 5 unneeded dependencies --> Running transaction check ---> Package apr.x86_64 0:1.3.9-5.el6_2 will be erased ---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be erased ---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be erased ---> Package httpd-tools.x86_64 0:2.2.15-29.el6.centos will be erased ---> Package mailcap.noarch 0:2.1.31-2.el6 will be erased --> Finished Dependency Resolution CDROM | 4.0 kB 00:00 ... Dependencies Resolved ============================================================================================================================================================================================================================================== Package Arch Version Repository Size ============================================================================================================================================================================================================================================== Removing: httpd x86_64 2.2.15-29.el6.centos @CDROM 2.9 M Removing for dependencies: apr x86_64 1.3.9-5.el6_2 @CDROM 296 k apr-util x86_64 1.3.9-3.el6_0.1 @CDROM 198 k apr-util-ldap x86_64 1.3.9-3.el6_0.1 @CDROM 9.3 k httpd-tools x86_64 2.2.15-29.el6.centos @CDROM 137 k mailcap noarch 2.1.31-2.el6 @CDROM 52 k Transaction Summary ============================================================================================================================================================================================================================================== Remove 6 Package(s) Installed size: 3.6 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : httpd-2.2.15-29.el6.centos.x86_64 1/6 Erasing : httpd-tools-2.2.15-29.el6.centos.x86_64 2/6 Erasing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 3/6 Erasing : mailcap-2.1.31-2.el6.noarch 4/6 Erasing : apr-util-1.3.9-3.el6_0.1.x86_64 5/6 Erasing : apr-1.3.9-5.el6_2.x86_64 6/6 Verifying : httpd-2.2.15-29.el6.centos.x86_64 1/6 Verifying : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 2/6 Verifying : httpd-tools-2.2.15-29.el6.centos.x86_64 3/6 Verifying : apr-1.3.9-5.el6_2.x86_64 4/6 Verifying : mailcap-2.1.31-2.el6.noarch 5/6 Verifying : apr-util-1.3.9-3.el6_0.1.x86_64 6/6 Removed: httpd.x86_64 0:2.2.15-29.el6.centos Dependency Removed: apr.x86_64 0:1.3.9-5.el6_2 apr-util.x86_64 0:1.3.9-3.el6_0.1 apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 httpd-tools.x86_64 0:2.2.15-29.el6.centos mailcap.noarch 0:2.1.31-2.el6 Complete! [root@web01 ~]#
Dengan begitu sekarang tidak ada lagi paket dependensi yang tertinggal :
[root@web01 ~]# rpm -qa | egrep "apr|httpd|mailcap" [root@web01 ~]#