apt-get en dpkg commands in Debian

Package management met apt-get

Debian en Ubuntu gebruiken apt voor de package management. Dit staat voor short for Advanced Package Tool. Hieronder volgen voorbeelden hoe packages kunnen worden beheerd.

Installeer software met apt waarbij <software> de naam van de package is (met * werkt ook om meerdere te installeren. Bijvoorbeeld: php5-* voor alle php5 packages.

apt-get install <software>

Updating de lijst met packages. Hierbij wordt de lijst met alle bestaande packages geupdate. De lijst wordt uit sources.apt gehaald.

apt-get update

Update alle software. Hierbij wordt alle geinstalleerde geupdate (dit commando wordt vaak direct na apt-get update uitgevoerd.

apt-get upgrade

To change the list of apt mirrors

apt-setup

Zoek een package

apt-cache search package

Verwijder geïnstalleerde software

apt-get remove software

Shortcuts

update the available package lists

dselect update

installs package

apt-get install pkg

uninstall package

apt-get remove pkg

show all installed and removed packages

dpkg -l

show install status of package

dpkg -l pkg

show all packages that match pattern

dpkg -S pattern

list packages that contain string

dpkg

list files in package

dpkg -L pkg

show status of package

dpkg -s pkg

show details of package

dpkg -p pkg

list relevant packages

apt-cache search string

install package from a deb file

dpkg -i file.deb

purge package (and config?)

dpkg -P pkg

re-run the configure for a package

dpkg-reconfigure pkg

get the source

apt-get source pkg

config build-deps for source and install as needed

apt-get build-dep

install package from specific release

apt-get -t release install pkg

prevent name from running at bootup

update-rc.d -f name remove

upgrade the distribution

apt-get dist-upgrade

 
I relied heavily on the dpkg and apt-cache commands to tell me what was already installed vs what packages were available in the repository. After completing that article it occurred to me that I should explain how to show what packages are currently installed… so here we are.

The command we need to use is dpkg –get-selections, which will give us a list of all the currently installed packages.

$ dpkg --get-selections
adduser                                         install
alsa-base                                       install
alsa-utils                                      install
apache2                                         install
apache2-mpm-prefork                             install
apache2-utils                                   install
apache2.2-common                                install
apt                                             install
apt-utils                                       install

The full list can be long and unwieldy, so it’s much easier to filter through grep to get results for the exact package you need. For instance, I wanted to see which php packages I had already installed through apt-get:

dpkg --get-selections | grep php
libapache2-mod-php5                             install
php-db                                          install
php-pear                                        install
php-sqlite3                                     install
php5                                            install
php5-cli                                        install
php5-common                                     install
php5-gd                                         install
php5-memcache                                   install
php5-mysql                                      install
php5-sqlite                                     install
php5-sqlite3                                    install
php5-xsl                                        install

Laat een reactie achter

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *