Dpkg
Dpkg (Debian Package) è un sistema di gestione dei pacchetti in Debian e distribuzioni Linux basate su Debian come Ubuntu.
Dpkg è in realtà un'utilità della riga di comando di basso livello per gestire i pacchetti. È diverso da strumenti come apt-get e gdebi.
Apt-get e Gdebi sono strumenti più avanzati in grado di risolvere le dipendenze e installarle in modo che il pacchetto principale funzioni correttamente.
In questo breve tutorial daremo un'occhiata ad alcuni esempi di base del comando dpkg e come usarlo per gestire i pacchetti sul tuo sistema.
Il comando dpkg funziona su sistemi come Debian, Ubuntu, Linux Mint e OS elementare.
Esempi di comandi Dpkg
1. Elenca tutti i pacchetti installati
Questo comando elencherà tutti i pacchetti installati. Le informazioni devono essere stampate in formato tabellare con colonne per Nome, versione, architettura e descrizione. L'elenco deve essere enorme e puoi scorrere su e giù.
$ dpkg -l Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-===============================================-===========================================-============-================================================= ii accountsservice 0.6.55-0ubuntu10 amd64 query and manipulate user account information ii accountwizard 4:19.04.3-0ubuntu1 amd64 wizard for KDE PIM applications account setup ii acl 2.2.53-4 amd64 access control list - utilities ii acpi-support 0.143 amd64 scripts for handling many ACPI events
2. Cerca i pacchetti installati
Puoi cercare nell'elenco dei pacchetti installati una voce particolare e vedere se è installata o meno.
Cerca nei pacchetti installati 'apache'
$ dpkg --get-selections | grep 'apache' apache2 install apache2-mpm-prefork install apache2-suexec install apache2-utils install apache2.2-bin install apache2.2-common install libapache-pom-java install libapache2-mod-fcgid install libapache2-mod-php5 install
Oppure usa la stessa l opzione per cercare i pacchetti installati. In realtà è più facile.
$ dpkg -l php* Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-===============================-====================-====================-==================================================================== un php-doc <none> (no description available) un php-imlib <none> (no description available) un php-kolab-filter <none> (no description available) un php-openid <none> (no description available) un php-pear <none> (no description available) un php-radius-legacy <none> (no description available) ii php5 5.4.6-1ubuntu1.2 all server-side, HTML-embedded scripting language (metapackage) ii php5-cgi 5.4.6-1ubuntu1.2 amd64 server-side, HTML-embedded scripting language (CGI binary) ii php5-cli 5.4.6-1ubuntu1.2 amd64 command-line interpreter for the php5 scripting language ii php5-common 5.4.6-1ubuntu1.2 amd64 Common files for packages built from the php5 source
3. Elenca i file installati da un pacchetto
Per trovare il percorso di tutti i file installati da un determinato pacchetto, usa l'opzione "L" con dpkg
$ dpkg -L php5-cli /. /etc /etc/php5 /etc/php5/cli /usr /usr/share /usr/share/man /usr/share/man/man1 /usr/share/man/man1/php5.1.gz /usr/share/doc /usr/share/lintian /usr/share/lintian/overrides /usr/share/lintian/overrides/php5-cli /usr/lib /usr/lib/php5 /usr/lib/php5/20100525 /usr/bin /usr/bin/php5 /etc/php5/cli/conf.d /usr/share/doc/php5-cli
Altri esempi
dpkg -i <package.deb> Installs a Debian package file; one that you downloaded manually, for example. dpkg -c <package.deb> Lists the contents of <package.deb>, a .deb file. dpkg -I <package.deb> Extracts package information from <package.deb>, a .deb file. dpkg -r <package> Removes an installed package named <package> dpkg -P <package> Purges an installed package named <package>. The difference between remove and purge is that while remove only deletes data and executables, purge also deletes all configuration files in addition. dpkg -L <package> Gives a listing of all the files installed by <package>. See also dpkg -c for checking the contents of a .deb file. dpkg -s <package> Shows information on the installed package <package>. See also apt-cache show for viewing package information in the Debian archive and dpkg -I for viewing package information extracted from a .deb file. dpkg-reconfigure <package> Reconfigures an installed package, if it uses debconf (debconf provides that consistent configuration interface for package installation). You can reconfigure debconf itself if you want to change the front-end or priority of questions asked. For example, to reconfigure debconf with the dialog front-end, you simply run: dpkg-reconfigure --frontend=dialog debconf echo ``<package> hold'' | dpkg --set-selections Put <package> on hold (command line method) dpkg --get-selections ``<package>'' Get the current status of <package> (command line method) dpkg -S <file> Searches for <file> in package database, telling you which packages have that file in them.
Riconfigura i pacchetti installati
I pacchetti possono essere riconfigurati utilizzando il comando dpkg-reconfigure.
Ad esempio riconfigurazione di phpmyadmin:
$ dpkg-reconfigure phpmyadmin
Conclusione
Questi erano alcuni esempi di base del comando dpkg. Nella maggior parte dei casi, probabilmente non utilizzeresti il pacchetto dpkg per la gestione dei pacchetti poiché è un comando di basso livello e fornisce solo funzionalità di base per l'installazione o la rimozione di pacchetti .deb.
Non gestisce i repository e non trova e non installa le dipendenze per il corretto funzionamento del pacchetto principale.
Gli altri comandi come apt-get, aptitude, apt, gdebi dovrebbero essere usati per installare e mantenere i pacchetti sul tuo sistema.
Se hai commenti o domande, faccelo sapere nei commenti qui sotto.