4 May 2013
Category:
Debian
Linux
Ubuntu
Comments: Comments Off on apt-get and dpkg commands on Debian and Ubuntu

apt-get and dpkg commands on Debian and Ubuntu

The RPM commands doesn’t work on Ubuntu or Debian. For these operating systems there is apt-get and dpkg commands. Here are some of the examples to list and get package information on debian and ubuntu servers.

List all packages installed server

root@sts:~# dpkg --get-selections
acl                                             install
adduser                                         install
apache2                                         install
apache2-mpm-prefork                             install
apache2-utils                                   install
apache2.2-bin                                   install
apache2.2-common                                install
apt                                             install
apt-utils                                       install
aptitude                                        install
authbind                                        install
avahi-daemon                                    install
awstats                                         install
base-files                                      install
...
...
...

Check if php package is installed on server or not

root@sts:~# dpkg --get-selections | grep php
libapache2-mod-php5                             install
php5                                            install
php5-cgi                                        install
php5-cli                                        install
php5-common                                     install
php5-curl                                       install
php5-gd                                         install
php5-imap                                       install
php5-ioncube-loader                             install
php5-mcrypt                                     install
php5-mysql                                      install
php5-sqlite                                     install
php5-xsl                                        install
psa-php5-configurator                           install
psa11-php-fakepackage                           install
root@h2153549:~#

List all files of a particular package

root@sts:~# dpkg -L libapache2-mod-php5
/.
/usr
/usr/lib
/usr/lib/php5
/usr/lib/php5/20090626
/usr/lib/apache2
/usr/lib/apache2/modules
/usr/lib/apache2/modules/libphp5.so
/usr/share
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/libapache2-mod-php5
/usr/share/doc
/etc
/etc/php5
/etc/php5/apache2
/etc/apache2
/etc/apache2/mods-available
/etc/apache2/mods-available/php5.conf
/etc/apache2/mods-available/php5.load
/usr/share/doc/libapache2-mod-php5
/etc/php5/apache2/conf.d

Check a file belongs to which package

root@sts:~# dpkg -S /usr/sbin/apache2
apache2-mpm-prefork: /usr/sbin/apache2
root@sts:~# dpkg -S /usr/lib/postfix/master
postfix: /usr/lib/postfix/master
root@sts:~#

Sometimes you want to know in what package is a file in. For that there is an utility called apt-file. First install the apt-file package

root@sts:~# apt-get install apt-file
root@sts:~# apt-file update

Now search for package which the file belongs to

root@sts:~# apt-file search flvtool2
flvtool2: /usr/bin/flvtool2
flvtool2: /usr/lib/ruby/1.8/flvtool2.rb
flvtool2: /usr/lib/ruby/1.8/flvtool2/base.rb
flvtool2: /usr/lib/ruby/1.8/flvtool2/version.rb
flvtool2: /usr/share/doc/flvtool2/README
flvtool2: /usr/share/doc/flvtool2/changelog.Debian.gz
flvtool2: /usr/share/doc/flvtool2/changelog.gz
flvtool2: /usr/share/doc/flvtool2/copyright
flvtool2: /usr/share/doc/flvtool2/examples/tags.xml
flvtool2: /usr/share/man/man1/flvtool2.1.gz

Comments are closed.