Sunday, January 1, 2012

Package Management


Debian based systems (including Ubuntu) uses apt-* commands for managing packages from the command line. Let us review how to use apt-* commands to view, install, remove, or upgrade packages.
APT is acronym for Advanced Package Tool. It supports installing packages over internet (ftp or http). You can also upgrade all packages in single operations, which makes it even more attractive.
Dpkg is Debian packaging tool which can be use to install, query, uninstall packages.

You can also try GUI based or high level interface to the Debian GNU/Linux package system. Such as:
1) aptitude: It is a text-based interface to the Debian GNU/Linux package system.
2) synaptic: GUI front end for APT
Rpm based Linux package names generally end in .rpm similarly Debian package names end in .deb, for example: apache_2.2.14_i386.deb
Install software using apt
$ apt-get install {package-name}
$ apt-get install php
Remove software using apt
$ apt-get remove {package-name}
$ apt-get remove php
Remove/erase package and configuration file
$ apt-get –purge remove {package-name}
$ apt-get –purge remove php
Updating the list of packages in your sources.list
$ apt-get update
Update software using apt
$ apt-get -u upgrade
$ apt-get upgrade php
To change the list of apt mirrors
$ apt-setup
Search for package
$ apt-cache search package
show all installed and removed packages
$ dpkg -l
show install status of package
$ dpkg -l apache
Verify if package sudo is install or not
$ dpkg -l | grep -i ‘apache’
List packages related to the apache:
$ dpkg -l ‘*apache*

List files owned by the installed package

# dpkg -L apache
What package owns the file
$ dpkg -S {/path/to/file}
$ dpkg -S /bin/netstat
show status of package
$ dpkg -s {package-name}
$ dpkg -s php
show details of package
$ dpkg -p php
list relevant packages
$ apt-cache search “network security”
Find out all denyhosts packages
$ apt-cache search denyhosts
install package from a deb file
$ dpkg -i {filename}.deb
purge package
$ dpkg -P php
re-run the configure for a package
$ dpkg-reconfigure php
get the source
$ apt-get source php
config build-deps for source and install as needed
$ apt-get build-dep
install package from specific release
$ apt-get -t {release} install php
prevent name from running at bootup
$ update-rc.d -f {name} remove
upgrade the distribution
$ apt-get –u dist-upgrade
How to know what packages may be upgraded
apt-show-versions is a program that shows what packages in the system may be updated and several useful information.