GNU/Linux >> Linux Esercitazione >  >> Linux

15 Esempi di comandi Yum Linux:installazione, disinstallazione, aggiornamento dei pacchetti

Installare, rimuovere e aggiornare i pacchetti è un'attività tipica su Linux. La maggior parte delle distribuzioni Linux fornisce una sorta di utilità di gestione dei pacchetti. Ad esempio, apt-get, dpkg, rpm, yum, ecc.

Su alcune distribuzioni Linux, yum è il gestore di pacchetti predefinito.

Yum sta per Yellowdog Updater modificato.

Questo articolo spiega con esempi i 15 comandi yum usati più di frequente.

1. Installa un pacchetto usando yum install

Per installare un pacchetto, fai 'yum install nomepacchetto'. Questo identificherà automaticamente anche le dipendenze e le installerà.

L'esempio seguente installa il pacchetto postgresql.

# yum install postgresql.x86_64
Resolving Dependencies
Install       2 Package(s)
Is this ok [y/N]: y

Package(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!

Per impostazione predefinita, "yum install", ti chiederà di accettare o rifiutare prima di installare i pacchetti. Se vuoi che yum si installi automaticamente senza che venga richiesto, usa l'opzione -y come mostrato di seguito.

# yum -y install postgresql.x86_64

2. Disinstalla un pacchetto usando yum remove

Per rimuovere un pacchetto (insieme a tutte le sue dipendenze), usa "yum remove package" come mostrato di seguito.

# yum remove  postgresql.x86_64
Resolving Dependencies
---> Package postgresql.x86_64 0:9.0.4-5.fc15 will be erased

Is this ok [y/N]: y

Running Transaction
  Erasing    : postgresql-9.0.4-5.fc15.x86_64       1/1 

Removed:
  postgresql.x86_64 0:9.0.4-5.fc15

Complete!

3. Aggiorna un pacchetto esistente usando yum update

Se hai una versione precedente di un pacchetto, usa "yum update package" per aggiornarlo all'ultima versione corrente. Questo identificherà e installerà anche tutte le dipendenze richieste.

# yum update postgresql.x86_64

4. Cerca un pacchetto da installare usando yum search

Se non conosci il nome esatto del pacchetto da installare, usa la "parola chiave di ricerca yum", che cercherà tutti i pacchetti che corrispondono alla "parola chiave" e la visualizzerà.

Gli esempi seguenti cercano nel repository yum tutti i pacchetti che corrispondono alla parola chiave "firefox" ed elencano i pacchetti disponibili.

# yum search firefox
Loaded plugins: langpacks, presto, refresh-packagekit
============== N/S Matched: firefox ======================
firefox.x86_64 : Mozilla Firefox Web browser
gnome-do-plugins-firefox.x86_64 : gnome-do-plugins for firefox
mozilla-firetray-firefox.x86_64 : System tray extension for firefox
mozilla-adblockplus.noarch : Adblocking extension for Mozilla Firefox
mozilla-noscript.noarch : JavaScript white list extension for Mozilla Firefox

Name and summary matches only, use "search all" for everything.

5. Visualizza informazioni aggiuntive su un pacchetto utilizzando yum info

Dopo aver cercato un pacchetto utilizzando la ricerca yum, puoi utilizzare "pacchetto informazioni yum" per visualizzare ulteriori informazioni sul pacchetto.

Gli esempi seguenti mostrano informazioni aggiuntive sul pacchetto samba-common.

# yum info samba-common.i686
Loaded plugins: langpacks, presto, refresh-packagekit
Available Packages
Name        : samba-common
Arch        : i686
Epoch       : 1
Version     : 3.5.11
Release     : 71.fc15.1
Size        : 9.9 M
Repo        : updates
Summary     : Files used by both Samba servers and clients
URL         : http://www.samba.org/
License     : GPLv3+ and LGPLv3+
Description : Samba-common provides files necessary for both the server and client
            : packages of Samba.

6. Visualizza tutti i pacchetti disponibili utilizzando yum list

Il comando seguente elencherà tutti i pacchetti disponibili nel database yum.

# yum list | less

7. Elenca solo i pacchetti installati usando yum list installed

Per visualizzare tutti i pacchetti installati sul tuo sistema, esegui il seguente comando yum.

# yum list installed | less

8. A quale pacchetto appartiene un file? – Usa yum fornisce

Usa "yum fornisce" se ti piace sapere a quale pacchetto appartiene un particolare file. Ad esempio, se desideri conoscere il nome del pacchetto che contiene il file /etc/sysconfig/nfs, procedi come segue.

# yum provides /etc/sysconfig/nfs
Loaded plugins: langpacks, presto, refresh-packagekit
1:nfs-utils-1.2.3-10.fc15.x86_64 : NFS utilities and supporting clients and
                                 : daemons for the kernel NFS server
Repo        : fedora
Matched from:
Filename    : /etc/sysconfig/nfs

1:nfs-utils-1.2.4-1.fc15.x86_64 : NFS utilities and supporting clients and
                                : daemons for the kernel NFS server
Repo        : updates
Matched from:
Filename    : /etc/sysconfig/nfs

1:nfs-utils-1.2.4-1.fc15.x86_64 : NFS utilities and supporting clients and
                                : daemons for the kernel NFS server
Repo        : installed
Matched from:
Other       : Provides-match: /etc/sysconfig/nfs

9. Elenca i gruppi di software disponibili utilizzando yum grouplist

In yum, diversi pacchetti correlati sono raggruppati in un gruppo specifico. Invece di cercare e installare tutti i singoli pacchetti che appartengono a una specifica funzione, puoi semplicemente installare il gruppo, che installerà tutti i pacchetti che appartengono al gruppo.

Per visualizzare tutti i gruppi di software disponibili, eseguire "yum grouplist" come mostrato di seguito. L'output è elencato in tre gruppi:Gruppi installati, Gruppi di lingua installati e Gruppi disponibili.

# 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
   ...

10. Installa un gruppo di software specifico utilizzando yum groupinstall

Per installare un gruppo di software specifico, utilizzare l'opzione di installazione di gruppo come mostrato di seguito. Nell'esempio seguente, il gruppo "DNS Name Server" contiene bind e bind-chroot.

# yum groupinstall 'DNS Name Server'

Dependencies Resolved
Install       2 Package(s)
Is this ok [y/N]: y

Package(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:15

Installed:
  bind-chroot.x86_64 32:9.8.0-9.P4.fc15

Dependency Installed:
  bind.x86_64 32:9.8.0-9.P4.fc15

Complete!

Nota:puoi anche installare il database MySQL usando yum groupinstall come discusso in precedenza.

11. Aggiorna un gruppo di software esistente utilizzando groupupdate

Se hai già installato un gruppo di software utilizzando yum groupinstall e desideri aggiornarlo all'ultima versione, utilizza "yum groupupdate" come mostrato di seguito.

# yum groupupdate 'Graphical Internet'

Dependencies Resolved
Upgrade       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!

12. Disinstalla un gruppo di software utilizzando yum groupremove

Per eliminare un gruppo di software esistente, usa "yum groupremove" come mostrato di seguito.

# yum groupremove 'DNS Name Server'
Dependencies Resolved
Remove        2 Package(s)
Is this ok [y/N]: y

Running 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!

13. Mostra i tuoi attuali repository yum

Tutti i comandi yum vanno contro uno o più repository yum. Per visualizzare tutti i repository yum configurati nel tuo sistema, esegui "yum repolist" come mostrato di seguito.

Di seguito verranno visualizzati solo i repository abilitati.

# yum repolist
repo id     repo name                        status
fedora      Fedora 15 - x86_64               24,085
updates     Fedora 15 - x86_64 - Updates     5,612

Per visualizzare tutti i repository (sia abilitati che disabilitati), usa "yum repolist all".

# yum repolist all
repo id                   repo name                                status
fedora                    Fedora 15 - x86_64                       enabled: 24,085
fedora-debuginfo          Fedora 15 - x86_64 - Debug               disabled
fedora-source             Fedora 15 - Source                       disabled
rawhide-debuginfo         Fedora - Rawhide - Debug                 disabled
rawhide-source            Fedora - Rawhide - Source                disabled
updates                   Fedora 15 - x86_64 - Updates             enabled:  5,612
updates-debuginfo         Fedora 15 - x86_64 - Updates - Debug     disabled
updates-source            Fedora 15 - Updates Source               disabled
updates-testing           Fedora 15 - x86_64 - Test Updates        disabled
updates-testing-debuginfo Fedora 15 - x86_64 - Test Updates Debug  disabled
updates-testing-source    Fedora 15 - Test Updates Source          disabled

Per visualizzare solo i repository disabilitati, usa "yum repository disabilitati".

14. Installa da un repository disabilitato usando yum –enablerepo

Per impostazione predefinita, yum si installa solo dai repository abilitati. Per qualche motivo, se ti piace installare un pacchetto da un repository disabilitato, usa l'opzione –enablerepo in 'yum install' come mostrato di seguito.

# yum --enablerepo=fedora-source install vim-X11.x86_64
Dependencies Resolved
Install       1 Package(s)
Is this ok [y/N]: y

Running Transaction
  Installing : 2:vim-X11-7.3.138-1.fc15.x86_64   1/1 

Complete!

15. Esegui i comandi yum in modo interattivo utilizzando Yum Shell

Yum fornisce la shell interattiva per eseguire più comandi come mostrato di seguito.

# yum shell
Setting up Yum Shell
> info samba.x86_64
Available Packages
Name        : samba
Arch        : x86_64
Epoch       : 1
Version     : 3.5.11
Release     : 71.fc15.1
Size        : 4.6 M
Repo        : updates
Summary     : Server and Client software to interoperate with Windows machines
URL         : http://www.samba.org/
License     : GPLv3+ and LGPLv3+
Description :
            : Samba is the suite of programs by which a lot of PC-related
            : machines share files, printers, and other information (such as
            : lists of available files and printers). The Windows NT, OS/2, and
            : Linux operating systems support this natively, and add-on packages
            : can enable the same thing for DOS, Windows, VMS, UNIX of all
            : kinds, MVS, and more. This package provides an SMB/CIFS server
            : that can be used to provide network services to SMB/CIFS clients.
            : Samba uses NetBIOS over TCP/IP (NetBT) protocols and does NOT
            : need the NetBEUI (Microsoft Raw NetBIOS frame) protocol.

> 

Yum può anche leggere i comandi da un file di testo ed eseguirlo uno per uno. Questo è molto utile quando si hanno più sistemi. Invece di eseguire lo stesso comando su tutti i sistemi, crea un file di testo con quei comandi e usa "yum shell" per eseguire quei comandi come mostrato di seguito.

# cat yum_cmd.txt
repolist
info nfs-utils-lib.x86_64

# yum shell yum_cmd.txt 
repo id     repo name                        status
fedora      Fedora 15 - x86_64               24,085
updates     Fedora 15 - x86_64 - Updates     5,612

Available Packages
Name        : nfs-utils-lib
Arch        : x86_64
Version     : 1.1.5
Release     : 5.fc15
Size        : 61 k
Repo        : fedora
Summary     : Network File System Support Library
URL         : http://www.citi.umich.edu/projects/nfsv4/linux/
License     : BSD
Description : Support libraries that are needed by the commands and
            : daemons the nfs-utils rpm.

Leaving Shell

Linux
  1. Oltre 15 esempi per il comando yum update

  2. 7 Esempi di comandi Linux df

  3. Esempi di comandi YUM per installare, rimuovere e aggiornare i pacchetti

  4. Esempi di comandi rm in Linux

  5. ps Esempi di comandi in Linux

Esempi di comandi Linux Rsync per principianti

Guida introduttiva agli esempi di comandi di Alpine Linux Apk

Comando RPM:15 esempi per installare, disinstallare, aggiornare, interrogare pacchetti RPM

10 esempi di esclusione Yum per saltare i pacchetti per l'aggiornamento Yum di Linux (come escludere gli aggiornamenti del kernel Yum)

Esempi di comandi id in Linux

apt comando Linux con esempi