Lệnh yum và các ví dụ

Thảo luận trong '1. Linux' bắt đầu bởi Cotdien, 30 Tháng bảy 2013.

  1. Cotdien

    Cotdien I'M NOTHING Staff Member

    Tham gia ngày:
    25 Tháng sáu 2013
    Bài viết:
    407
    Đã được thích:
    1
    Điểm thành tích:
    18
    - Cũng như muốn note lại và chia sẻ với mọi người. Đây là các lệnh căn bản mà ai cũng phải nắm được nhé ^^.

    [​IMG]
    1. Yum là con mẹ gì ^^ ??
    Yum stands for Yellowdog Updater Modified.
    Nó thường có mặc định trên các bản phân phối linux. Yum là một gói tương tự như apt-get, dpkg, rpm ...Hoạt động chủ yếu như tên của nó: cài đặt, gở bỏ, cập nhật các gói trên linux.

    2. Yum làm được cái vếu gì ??

    - Cài đặt gói phần mềm :


    yum install postgresql.x86_64

    Resolving DependenciesInstall 2 Package(s)Is this ok [y/N]: yPackage(s) data still to download: 3.0 M(1/2): postgresql-9.0.4-5.fc15.x86_64.rpm | 2.8 MB 00:11(2/2): postgresql-libs-9.0.4-5.fc15.x86_64.rpm | 203 kB 00:00------------------------------------------------------------------Total 241 kB/s | 3.0 MB 00:12 Running Transaction Installing : postgresql-libs-9.0.4-5.fc15.x86_64 1/2 Installing : postgresql-9.0.4-5.fc15.x86_64 2/2 Complete!

    Mặc định khi cài, đòi hỏi bạn xác nhận cài đặt gói này không (y or enter), để bỏ qua bước này chỉ cần thêm tham số -y trước hoặc sau:

    yum install postgresql.x86_64 -y
    - Gở bỏ một gói đã cài


    yum remove postgresql.x86_64

    Resolving Dependencies---> Package postgresql.x86_64 0:9.0.4-5.fc15 will be erasedIs this ok [y/N]: yRunning Transaction Erasing : postgresql-9.0.4-5.fc15.x86_64 1/1 Removed: postgresql.x86_64 0:9.0.4-5.fc15Complete!

    - Nâng cấp gói phần mềm hiện đã có


    yum update postgresql.x86_64

    - Tìm kiếm gói cần cài đặt


    yum search firefox
    Loaded plugins: langpacks, presto, refresh-packagekit============== N/S Matched: firefox ======================firefox.x86_64 : Mozilla Firefox Web browsergnome-do-plugins-firefox.x86_64 : gnome-do-plugins for firefoxmozilla-firetray-firefox.x86_64 : System tray extension for firefoxmozilla-adblockplus.noarch : Adblocking extension for Mozilla Firefoxmozilla-noscript.noarch : JavaScript white list extension for Mozilla FirefoxName and summary matches only, use "search all" for everything.

    - Hiển thị thông tin gói

    yum info zip

    Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.vonline.vn * extras: mirrors.vonline.vn * updates: mirrors.vonline.vnInstalled PackagesName : zipArch : x86_64Version : 3.0Release : 1.el6Size : 804 kRepo : installedFrom repo : baseSummary : A file compression and packaging utility compatible with PKZIPURL : http://www.info-zip.org/Zip.htmlLicense : BSDDescription : The zip program is a compression and file packaging utility. Zip : is analogous to a combination of the UNIX tar and compress : commands and is compatible with PKZIP (a compression and file : packaging utility for MS-DOS systems). : : Install the zip package if you need to compress files using the : zip program.

    - Xem các gói hiện có


    yum list | lessor yum list | less|more

    - Xem các gói đã cài

    yum list installed | lessor yum list installed | grep zip
    - Xem thư viện or file thuộc gói nào, của thằng nào


    yum provides */hosts

    Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.vonline.vn * extras: mirrors.vonline.vn * updates: mirrors.vonline.vnavahi-0.6.25-12.el6.x86_64 : Local network service discoveryRepo : baseMatched from:Filename : /etc/avahi/hostsnscd-2.12-1.107.el6.x86_64 : A Name Service Caching Daemon (nscd).Repo : baseMatched from:Filename : /var/run/nscd/hostsFilename : /var/db/nscd/hostssetup-2.8.14-20.el6.noarch : A set of system configuration and setup filesRepo : baseMatched from:Filename : /etc/hostsavahi-0.6.25-12.el6.i686 : Local network service discoveryRepo : baseMatched from:Filename : /etc/avahi/hostssetup-2.8.14-20.el6.noarch : A set of system configuration and setup filesRepo : installedMatched from:Filename : /etc/hosts

    - Hiển thì nhóm : đôi khi trong yum một số gói liên quan với nhau, thay vì cài đặt từng nhóm ta có thể cài đặt nguyên group bao gồm các gói này

    yum grouplist

    Installed Groups: Administration Tools Base Design Suite ....Installed Language Groups: Arabic Support [ar] Armenian Support [hy] Bengali Support [bn] ....Available Groups: Authoring and Publishing Books and Guides Clustering DNS Name Server Development Libraries Development Tools Directory Server Dogtag Certificate System ...

    - Cài đặt một nhóm gói


    yum groupinstall 'DNS Name Server'

    Dependencies ResolvedInstall 2 Package(s)Is this ok [y/N]: yPackage(s) data still to download: 3.6 M(1/2): bind-9.8.0-9.P4.fc15.x86_64.rpm | 3.6 MB 00:15(2/2): bind-chroot-9.8.0-9.P4.fc15.x86_64.rpm | 69 kB 00:00-----------------------------------------------------------------Total 235 kB/s | 3.6 MB 00:15Installed: bind-chroot.x86_64 32:9.8.0-9.P4.fc15Dependency Installed: bind.x86_64 32:9.8.0-9.P4.fc15Complete!
    - Nâng cấp

    yum groupupdate 'Graphical Internet'

    Dependencies ResolvedUpgrade 5 Package(s)Is this ok [y/N]: y Running Transaction Updating : evolution-data-server-3.0.2-1.fc15.x86_64 1/10 Updating : evolution-3.0.2-3.fc15.x86_64 2/10 Updating : evolution-NetworkManager-3.0.2-3.fc15.x86_64 3/10 Updating : evolution-help-3.0.2-3.fc15.noarch 4/10 Updating : empathy-3.0.2-3.fc15.x86_64 5/10 Cleanup : evolution-NetworkManager-3.0.1-1.fc15.x86_64 6/10 Cleanup : evolution-help-3.0.1-1.fc15.noarch 7/10 Cleanup : evolution-3.0.1-1.fc15.x86_64 8/10 Cleanup : empathy-3.0.1-3.fc15.x86_64 9/10 Cleanup : evolution-data-server-3.0.1-1.fc15.x86_64 10/10 Complete!

    - Gỡ bỏ


    yum groupremove 'DNS Name Server'
    Dependencies ResolvedRemove 2 Package(s)Is this ok [y/N]: yRunning Transaction Erasing : 32:bind-chroot-9.8.0-9.P4.fc15.x86_64 1/2 Erasing : 32:bind-9.8.0-9.P4.fc15.x86_64 2/2 Complete!
    - Đang dùng kho yum nào

    yum repolist
    Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.vonline.vn * extras: mirrors.vonline.vn * updates: mirrors.vonline.vnrepo id repo name statusbase CentOS-6 - Base 6,381extras CentOS-6 - Extras 12updates CentOS-6 - Updates 467repolist: 6,860You have new mail in /var/spool/mail/root

    - Liệt kê

    yum repolist all
    Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirrors.vonline.vn * extras: mirrors.vonline.vn * updates: mirrors.vonline.vnrepo id repo name statusC6.0-base CentOS-6.0 - Base disabledC6.0-centosplus CentOS-6.0 - CentOSPlus disabledC6.0-contrib CentOS-6.0 - Contrib disabledC6.0-extras CentOS-6.0 - Extras disabledC6.0-updates CentOS-6.0 - Updates disabledC6.1-base CentOS-6.1 - Base disabledC6.1-centosplus CentOS-6.1 - CentOSPlus disabledC6.1-contrib CentOS-6.1 - Contrib disabledC6.1-extras CentOS-6.1 - Extras disabledC6.1-updates CentOS-6.1 - Updates disabledC6.2-base CentOS-6.2 - Base disabledC6.2-centosplus CentOS-6.2 - CentOSPlus disabledC6.2-contrib CentOS-6.2 - Contrib disabledC6.2-extras CentOS-6.2 - Extras disabledC6.2-updates CentOS-6.2 - Updates disabledC6.3-base CentOS-6.3 - Base disabledC6.3-centosplus CentOS-6.3 - CentOSPlus disabledC6.3-contrib CentOS-6.3 - Contrib disabledC6.3-extras CentOS-6.3 - Extras disabledC6.3-updates CentOS-6.3 - Updates disabledbase CentOS-6 - Base enabled: 6,381c6-media CentOS-6 - Media disabledcentosplus CentOS-6 - Plus disabledcontrib CentOS-6 - Contrib disableddebug CentOS-6 - Debuginfo disabledextras CentOS-6 - Extras enabled: 12updates CentOS-6 - Updates enabled: 467repolist: 6,860
    - Install từ thư viện bị disabled : Mặc định yum chỉ cho phép từ các thư việc cho phép (enabled), nhưng nếu muốn cài đặt các gói không có trong repo cho phép thì làm thế nào ?


    yum --enablerepo=fedora-source install vim-X11.x86_64
    Dependencies ResolvedInstall 1 Package(s)Is this ok [y/N]: yRunning Transaction Installing : 2:vim-X11-7.3.138-1.fc15.x86_64 1/1 Complete!
     

Chia sẻ trang này