Debian based systems (including Ubuntu) uses apt-* commands for managing packages from the command line.
In this article, using Apache 2 installation as an example, let us review how to use apt-* commands to view, install, remove, or upgrade packages.
1. apt-cache search: Search Repository Using Package Name If you are installing Apache 2, you may guess that the package name is apache.2. To verify whether it is a valid package name, you may want to search the repository for that particular package name as shown below.
In this article, using Apache 2 installation as an example, let us review how to use apt-* commands to view, install, remove, or upgrade packages.
1. apt-cache search: Search Repository Using Package Name If you are installing Apache 2, you may guess that the package name is apache.2. To verify whether it is a valid package name, you may want to search the repository for that particular package name as shown below.
The following example shows how to search the repository for a specific package name.
$ apt-cache search ^apache2$apache2 - Apache HTTP Server metapackage
2. apt-cache search: Search Repository Using Package Description
If you don’t know the exact name of the package, you can still search using the package description as shown below.
$ apt-cache search "Apache HTTP Server"apache2 - Apache HTTP Server metapackageapache2-doc - Apache HTTP Server documentationapache2-mpm-event - Apache HTTP Server - event driven modelapache2-mpm-prefork - Apache HTTP Server - traditional non-threaded modelapache2-mpm-worker - Apache HTTP Server - high speed threaded modelapache2.2-common - Apache HTTP Server common files
3. apt-file search: Search Repository Using a Filename from the Package
Sometimes you may know the configuration file name (or) the executable name from the package that you would like to install.
The following example shows that apache2.conf file is part of the apache2.2-common package. Search the repository with a configuration file name using apt-file command as shown below.
$ apt-file search apache2.confapache2.2-common: /etc/apache2/apache2.confapache2.2-common: /usr/share/doc/apache2.2-common/examples/apache2/apache2.conf.gz
4. apt-cache show: Basic Information About a Package
Following example displays basic information about apache2 package.
$ apt-cache show apache2Package: apache2Priority: optionalMaintainer: Ubuntu Core DevelopersOriginal-Maintainer: Debian Apache MaintainersVersion: 2.2.11-2ubuntu2.3(>= 2.2.11-2ubuntu2.3)| apache2-mpm-prefork (&gDepends: apache2-mpm-workert;= 2.2.11-2ubuntu2.3)| apache2-mpm-event (>= 2.2.11-2ubuntu2.3)6350Description: Apache HTTP Server metapackageThe Apache SoFilename: pool/main/a/apache2/apache2_2.2.11-2ubuntu2.3_all.debSize:4ftware Foundation's goal is to build a secure, efficient andextensible HTTP server as standards-compliant open source software.Homepage: http://httpd.apache.org/
5. apt-cache showpkg: Detailed Information About a Package
“apt-cache show” displays basic information about a package. Use “apt-cache showpkg” to display detailed information about a package as shown below.
$ apt-cache showpkg apache2Package: apache2Versions:untu2.3 (/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_jaunty-updates_main_binary-i386_Packages) (/var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_jaunty-security_main_binary-i386_Packages)Descript2.2.11-2ubion Language:File: /var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_jaunty-updates_main_binary-i386_PackagesMD5: d24f049cd70ccfc178dd8974e4b1ed01Reverse Depends:squirrelmail,apache2squid3-cgi,apache2mahara-apache2,apaphpmyadmin,apache2che2 ipplan,apache2Dependencies:2.2.11-2ubuntu2.3 - apache2-mpm-worker (18 2.2.11-2ubuntu2.3) apache2-mpm-prefork (18 2.2.11-2ubuntu2.3) apache2-mpm-event (2 2.2.11-2ubuntu2.3)2.2.11-2ubuntu2 - apache2-mpm-worker (18 2.2.11-2ubuntu2) apache2-mpm-prefork (18 2.2.11-2ubuntu2) apache2-mpm-event (2 2.2.11-2ubuntu2)Provides:2.2.11-2ubuntu2.3 -2.2.11-2ubuntu2 -Reverse Provides:apache2-mpm-itk 2.2.6-02-1build4.3apache2-mpm-worker 2.2.11-2ubuntu2.3apache2-mpm-prefork 2.2.11-2ubuntu2.3apache2-mpm-prefork 2.2.11-2ubuntu2 apache2-mpm-event 2.2.11-2ubuntu2
6. apt-file list: List all the Files Located Inside a Package
Use “apt-file list” to display all the files located inside the apache2 package as shown below.
$ apt-file list apache2 | moreapache2: /usr/share/bug/apache2/controlapache2: /usr/share/bug/apache2/scriptbian.gzapache2: /usr/share/doc/apache2/READMEapache2: /usr/share/doc/apache2/NEWS.De.Debian.gzapache2: /usr/share/doc/apache2/changelog.Debian.gz...
7. apt-cache depends: List all Dependent Packages
Before installation, if you like to view all the dependent packages, use “apt-cache depends” as shown below.
$ apt-cache depends apache2apache2|Depends: apache2-mpm-worker|Depends: apache2-mpm-preforkDepends: apache2-mpm-event
8. dpkg -l: Is the Package Already Installed?
Before installing a package, you may want to make sure it is not already installed as shown below using dpkg -l command.
$ dpkg -l | grep -i apache
9. apt-get install: Install a Package
Finally, install the package using “apt-get install” as shown below.
$ sudo apt-get install apache2[sudo] password for ramesh:he following NEW packages will be installed:T apache2 apache2-mpm-worker apache2-utils apache2.2-common libapr1libaprutil1 libpq5stalled, 0 to remove and 26 not upgraded.0 upgraded, 7 newly in
10. dpkg -l : Verify Whether the Package got Successfully Installed
After installing the package, use “dpkg -l” to make sure it got installed successfully.
$ dpkg -l | grep apacheii apache2 2.2.11-2ubuntu2.3 Apache HTTP Server metapackageii apache2-mpm-worker 2.2.11-2ubuntu2.3 Apache HTTP Server - high speed threaded modii apache2-utils 2.2.11-2ubuntu2.3 utility programs for webserversii apache2.2-common 2.2.11-2ubuntu2.3 Apache HTTP Server common files
11. apt-get remove: Delete a Package
Use “apt-get purge” or “apt-get remove” to delete a package as shown below.
$ sudo apt-get purge apache2(or)sudo apt-get remove apache2$The following packages were automatically installed and are no longer required:apache2-utils linux-headers-2.6.28-11 libapr1 apache2.2-common util1Use 'apt-get autoremove' to remove them.The following packageslinux-headers-2.6.28-11-generic apache2-mpm-worker libpq5 libaprwill be REMOVED:apache2, 0 newly installed, 1 to remove and 26 not upgraded.0 upgradedRemoving apache2 ...
- apt-get remove will not delete the configuration files of the package
- apt-get purge will delete the configuration files of the package
12. apt-get -u install: Upgrade a Specific Package
The following example shows how to upgrade one specific package.
$ sudo apt-get -u install apache2Reading package lists... DoneBuilding dependency tree... Doneapache2 is already the nReading state informationewest version.ckages were automatically installed and are no longer required:linux-headersThe following pa-2.6.28-11 linux-headers-2.6.28-11-genericUse 'apt-get autoremove' to remove them.0 upgraded, 0 newly installed, 0 to remove and 26 not upgraded.
13. apt-get -u upgrade: Upgrade all Packages
To upgrade all the packages to it’s latest version, use “apt-get -u upgrade” as shown below.
$ sudo apt-get -u upgradeThe following packages will be upgraded: libglib2.0-0 libglib2.0-data libicu38 libsmbclient libwbclient0 openoffice.org-base-core openoffice.org-calc openoffice.org-common openoffice.org-core openoffice.org-draw openoffice.org-emailmerge openoffice.org-gnome openoffice.org-gtk openoffice.org-impress openoffice.org-math openoffice.org-style-human openoffice.org-writer python-uno samba-common smbclient ttf-opensymbol tzdata 26 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
0 comments:
Post a Comment