Getting started with Apt-get/dpkg for Debian Linux

Source: Internet
Author: User

Brief Translation: the original article is on the Blog of All about Linux. In fact, there is a more comprehensive apt howto that has been translated for a long time, which is strongly recommended.

Debian is one of the earliest Linux releases. It can attract public attention because it makes it very easy to install and uninstall software. When other releases are stuck in the dependency quarary, Debian users are immune from these problems because of a better package management system.

All Debian-based distributions use this package management system. The Deb package can package the files of an application together, basically like the installation files on Windows. Here we will introduce how to use the installation package processing software to achieve our goal.

The first step to use apt-get is to introduce the necessary software libraries. The Debian software libraries are the collection of all Debian software packages, which exist on some public websites on the Internet. Add their addresses to apt-get to search for the software we want. /Etc/apt/sources. list is the configuration file that stores these address lists. The format is as follows:

Deb [web or ftp address] [release name] [main/contrib/non-free]

For example, Ubuntu is a Debian-based release, and its Sources. list can be like this:

Deb http://in.archive.ubuntu.com/ubuntu breezy main restrcted

You can add your own address. The apt-get.org has some nice address lists.

After setting the address, you must synchronize the software library on the local machine with the online library, but only the software description information, excluding the software itself ). In this way, a list of available software is available on the local machine. The command is as follows:

# Apt-get update

After running successfully, you can find the software in your release. The command is apt-cache, and the command is retrieved on the local machine instead of connected to the Internet. For example:

# Apt-cache search baseutils

This command can be used to list the situation of the baseutils software package, such as whether it is available or not.

You can install this software package in the Library:

# Apt-get install baseutils

Now we can see the power of apt-get. If baseutils depends on another software or a Runtime Library xyz.0.01.so, apt-get will automatically download this package or the software package containing this library ). This is called automatic dependency processing. Generally, if you only use the software in the Debian software library, you will not find the package or the package version is incorrect, unless you use the Testing or Unstable version being developed.

Uninstall software:

# Apt-get remove baseutils

If you want to see how many software is in the Library:

# Apt-cache stats
Total package names: 22502 (900 k)
Normal packages: 17632
Pure virtual packages: 281
Single virtual packaging: 1048
Mixed virtual packages: 172
Missing: 3369
...

Upgrade all software on the local machine to the latest version:

# Apt-get upgrade

Finally, the most powerful version -- upgrade the entire release to the new version:

# Apt-get dist-upgrade

During the upgrade, pay attention to the things that affect system startup, such as upgrading the kernel, grub or lilo. After that, you should re-run grub or lilo to point them to the correct position, otherwise, the upgrade will fail.

When you install the software with apt-get, it will be posted on sources from the Internet. the software package used for downloading. The package will be stored on the local machine. The directory is/var/cache/apt/archives /. After a long time, it will become very huge and occupy a lot of hard disk space. To clear this directory, run:

# Apt-get clean

There is also an automatic cleanup function that only clears useless or incomplete software packages:

# Apt-get autoclean

In this way, you can still use the downloaded software when you reinstall it, instead of downloading it online.

Dpkg-some underlying package management tools

Usually, you do not need to process a single deb file. If necessary, run the dpkg command. For example, you want to install gedit yourself:

# Dpkg-I gedit-2.12.1.deb

Uninstall:

# Dpkg-r gedit

Write the name here. You can also add the -- purge (-P) Flag:

# Dpkg-P gedit

This will be deleted together with the gedit configuration file. If only-r is used, the configuration file will not be deleted.

If you do not want to install a deb package, but want to see what files it contains:

# Dpkg-c gedit-2.12.1.deb

If you want to view more information:

# Dpkg-I gedit-2.12.1.deb

You can also use wildcards to list the software on the machine:

# Dpkg-l gcc *

This will list all software packages starting with gcc:

Desired = Unknown/Install/Remove/Purge/Hold
Status = Not/Installed/Config-files/Unpacked/Failed-config /.
/Err? = (None)/Hold/Reinst-required/X = both-problems
/Name Version Description
++-=================================================== ==============================
Ii gcc 4.0.1-3 The gnu c compiler
Ii gcc-3.3-base 3.3.6-8ubuntu1 The GNU Compiler Colletio
Ungcc-3.5 none (no description available)

Among them, 1st I indicates that you want to install, 2nd I indicates that you have installed, and 3rd fields are problematic if any.) The meaning of the three words can be viewed in the above three lines, desired, status, err), followed by the name, version, and description. Un indicates Unknown, not-installed.

If you want to see if a package has been installed:

# Dpkg-s gedit

If you want to see what files are installed in a software, where:

# Dpkg-L gedit

If you only want to view some of the files, add Grep:

# Dpkg-L gedit grep png

Of course, there are also aptitude and Aptitude. The former is a menu-based tool running on the terminal, and the latter is a graphical program running on the X Window.

Also, list the details of a package: apt-cache show gedit

Some Mandatory Commands: dpkg -- force-help

Related Articles]

  • Apt-get command update

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.