Linux software installation and management of --dpkg apt- * Detailed

 Linux software installation and management of --dpkg apt- * Detailed

[Linux software installation Management Series] - - Portal:

- - " Linux Software Installation - The installation Detailed source "

- - " Linux software installation and management of --RPM Detailed YUM "

- - "Linux software installation and management of --dpkg apt- * Detailed"

I. Preamble

        Previous article " Linux Software Installation - The installation Detailed source " details the principle source packages installed under Linux platform, although the use of the software source code compiler may have customized settings, but Linux distribution for publishers to that there is no later software management problem, after all, not everyone will be compiling source code. This issue will be issued with a severe impact on the promotion of linux platform software.

        In order to solve the above problems, the first manufacturers in their system above compiled software users we need, then this software is compiled and executed released directly to the user to install. Different Linux distributions use different packaging system, in general, most of the releases were part of two package management technology camp: Debian of ".deb", and Red Hat's ".rpm". There are some important exceptions, say Gentoo, Slackware, and Foresight, but most will use one of these two basic systems.

        Here we will introduce a series of releases of Debian dpkg and apt- * detailed use, such as the need to understand Red Hat series distribution's package management system can see my other article: " Linux software installation management of --RPM Detailed and YUM . "

        Note: I [Ubuntu 12.04 LTS system version]

 

Two, dpkg

1 Introduction

        dpkg - package manager for Debian (debian package management system tools).

        dpkg is a tool to install, build, remove and manage Debian packages, dpkg is an underlying Debian package management tools, mainly used for local downloaded and installed packages to be managed.

        This mechanism was first proposed by dpkg Debian Linux community developed, through the mechanism of dpkg, the Debian software will be able to provide simple to install, and can provide information after the software is installed, it is very good. As long as derived from other Linux distributions Debian's dpkg mostly use this mechanism to manage, including B2D, Ubuntu and so on.

 

2, deb package names rules

Format: Package_Version-Build_Architecture.deb

如: nano_1.3.10-2_i386.deb

* Package name (Package Name): nano

* Version (Version Number): 1.3.10

* Revision number (Build Number): 2

* Platform (Architecture): i386

 

3, dpkg package introduced relevant documents

/etc/dpkg/dpkg.cfg dpkg package management software configuration files Configuration file with default options []

Log Files /var/log/dpkg.log dpkg package management software [Default log file (see /etc/dpkg/dpkg.cfg(5) and option --log)]

Information package / var / lib / dpkg / available storage systems installed all over the [List of available packages.]

/ Var / lib / dpkg / status storage systems are now all installed software state information

/ Var / lib / dpkg / info remember to install the package control file control information directory

 

4, dpkg database

        dpkg using a text file as a database to maintain system software, including the list of documents, dependencies, software status, etc. detailed contents, usually in / var / lib / dpkg directory. Typically stores software status and control information in the status file. In info / directory backup control file, and records the installation file in the list of files in its .list, MD5 coding .mdasums save the file under it.

Example: dpkg database query (show all installed Deb package)

 
dpkg -l

        As shown above, a record for each package, noted that the first, two, three characters per record, this is the state identified package, the package is behind so name, version number and a brief description.

1) a first character to a desired value (Desired = Unknown / Install / Remove / Purge / Hold), comprising:

u Unknown status is unknown, which means that the package is not installed, and the user has not issued the installation request.

i Install user requests installation package.

r Remove user requests uninstall packages.

p Purge purge packages requested by the user.

h Hold the user request remains locked version of the package.

2) the second column, the current state of the package (Status = Not / Inst / Conf-files / Unpacked / halF-conf / Half-inst / trig-aWait / Trig-pend)

n Not packages are not installed.

i Inst package installation and configuration is complete.

c Conf-files previously installed software package, now removed, but its configuration files remain in the system.

u Unpacked package is unpacked, but has not been configured.

f halF-conf trying to configure the package, but failed.

h Half-inst package is installed, but without success.

w trig-aWait wait flip-flop

t Trig-pend trigger pending

3) The third column identifies the error state, a first state flag is no problem, the null symbol identifying the respective other issues / Reinst-required. (Err = (none?) (Status, Err: uppercase = bad))

h package is forced to remain because there are other packages depend on demand, can not be upgraded.

r Reinst-required, the package is damaged, you may need to reinstall normal use (including deletion).

x software package is destroyed, and is forcibly held.

Case Description:

ii - denotes the software system is installed properly

pn - Indicates that the software, and later cleared

un - said they had never installed the software

iu - represents the software was installed, but not configured

rc - This software has been removed, but the configuration file is still

 

5, dpkg subcommand

For the convenience of users, dpkg not only provides a large number of parameter options, but also provides a number of sub-commands.

such as:

dpkg-deb、dpkg-divert、dpkg-query、dpkg-split、dpkg-statoverride、start-stop-daemon

There will not be a detailed description of the dpkg command For access to the information on their own.

 

Three, dpkg manual

1, the installation

1) related to the installation command

dpkg -i package-name.deb # --install, installation packages, you must be the full name deb package. (Software installation can be split into two opposing processes "unbundling" and "Configuration")

dpkg --unpack package-name.deb # "unpack": Decompress the package, but is not configured to the system directory, if used with -R, parameters can be a directory

dpkg --configure package-name.deb # "Configuration": Configuration Package

dpkg -c package-name.deb # list the contents of a deb package

2) Installation related options

-R, --recursive Recursively handle all regular files matching pattern * .deb found at specified directories and all of its subdirectories. This can be used with -i, -A, --install, --unpack and --avail actions ( recursively all directed to a particular directory installation package, may be combined -i, used together -A, --install, --unpack and --avail)

2, remove packages

dpkg -r package-name # --remove, remove the package but not its configuration files

dpkg -P package-name # --purge, remove all the files package (removes everything, including conffiles)

 

3, the query

dpkg -l package-name-pattern # --list, view the system in package names package that conforms to pattern mode

dpkg -L package-name # --listfiles, view the file and directory package-name corresponding package installation

dpkg -p package-name # --print-avail, show specific packet

dpkg -s package-name # --status, see the package-name corresponding to the package information (already installed)

dpkg -S filename-search-pattern # --search, find the package that contains the name of the filename from installed packages in

(Tip: subcommand also be used to query dpkg-query operation)

Example 1: List of related packages installed on the system dpkg

dpkg -l \*dpkg*

Example 2: View dpkg package installation to the file system

dpkg -L dpkg

More dpkg to use the command line can be used in man dpkg to view it or directly use dpkg --help .

 

Three, apt

1, apt Profile

        While we use dpkg , the problem has been to get rid of a lot of the software installation process, but when the dependency is not met, still need to manually resolved, and apt tool to solve this problem, linux distribution first placed into the corresponding software servers, and analysis software dependencies, and recorded, and then when a client has installed software requirements, through the inventory list with local dpkg software data exist comparing, you can get all required from the network have the software-dependent attributes.

 

2, the working principle

        Ubuntu centralized depot mechanism to package a variety of different categories stored in the depot to effectively organize and manage. Then, the depot placed many mirror servers, and keep consistent. Thus, all Ubuntu users can get the latest version of the installation package at any time. Therefore, for the user, these mirrors is their source software (Reposity)

       However, due to the different network environment in which each user is not possible to freely visit various mirror sites. In order to be able to selectively access in the Ubuntu system, using software source configuration file /etc/apt/sources.list list of mirror sites to access the most appropriate address.

Example 1: apt-get update process

1) execute apt-get update

2) program analysis /etc/apt/sources.list

3) Automatic networking to find the corresponding list of Packages / Sources / Release list of files, if an update is downloaded, the deposit / var / lib / apt / lists / directory

4) is then apt-get install corresponding packet, to download and install.

        Even so, the software source configuration files just told Ubuntu mirror site address system that can be accessed, but those mirror sites have specific software resources What is not clear. If each installation of a software package, you look for it again on the server, the efficiency is very low. Thus, it is necessary to make a list of these software resources (index files) to the local host queries.

        Users can use the "apt-get update" command to refresh the software source, to create an updated list of packages. In Ubuntu Linux in, "apt-get update" command scans each source server software and software packages have the resources for that server to index files stored locally in / var / lib / apt / lists / directory. Use apt-get to perform the installation, update operation, it will be based on these index files, application software resources to the source server. Therefore, when the computer is idle equipment, often use "apt-get update" command to refresh source software, it is a good habit.

Example 2: apt-get install Schematic

 
 

3, apt-related documents

SUMMARY var / lib / dpkg / available document information package is described, which includes all the software installation source Debian packages used in the current system, including the current system has been installed and the package is not installed.

/etc/apt/sources.list recording software source address (when you run sudo apt-get install xxx, Ubuntu go to these sites to download the package and perform the installation locally)

/ Var / cache / apt / archives have been downloaded to the packages are placed here (when using apt-get install to install the software, temporary storage path package)

/ Var / lib / apt / lists using apt-get update command to download the software from the list /etc/apt/sources.list and save to that directory

4, the source file

        /etc/apt/sources.list apt source file specified by the configuration file, the configuration file memory as shown below:

 
sources.list

        The storage position of the mirror server:

 
 

        By unpacked Packages.gz we can see basic information about all packages, and Packages.gz already contains all depends software and version information, as well as download address.

Four, apt manual

1、apt-get

        apt-get is the command-line tool for handling packages, and may be considered the user's "back-end" to other tools using the APT library. Several "front-end" interfaces exist, such as dselect(1), aptitude(8), synaptic(8) and wajig(1).

        apt-get is a simple command to download and install packages line interface. The most commonly used commands are update (Update) and install (installation).

Usage: apt-get [options] command

Common options:

-h This help file.

-q output to the log - no indication of progress

-qq not output, except error

-d Download only - do not install or unpack archives

-s no actual installation. Run the simulation

-y assumes that the election is all inquiries without prompting

-f attempt at damage-dependent correction system

-m If the archive can not be located, attempt to continue

-u simultaneously displays a list of update packages

-b get after source package compiled

-V Displays detailed version number

-c =? Read this configuration file

-o =? set a custom configuration options, such as -o dir :: cache = / tmp

Commonly used commands:

1) apt-get update update source

     【aptitude update】

2) apt-get dist-upgrade system upgrade to a corresponding release (according source.list configuration)

     【aptitude dist-upgrade】

3) apt-get upgrade to update all installed packages

     【aptitude upgrade】

4) apt-get install package_name install software packages (plus --reinstall reinstall)

    apt-get install package_name = version to install the specified version of the software package

    【aptitude install package_name】

5) apt-get remove package_name uninstall a package installed (keep config)

    【aptitude remove package_name】

6) apt-get purge package_name remove packages (remove configuration information)

     或apt-get  --purge remove packagename

    【aptitude purge package_name】

7) apt-get check check dependency of damage

8) apt-get autoclean to delete you have deleted the software (running on a regular basis this command to remove .deb files that have been uninstalled packages. In this way, you can release large amounts of disk space. If your demand is very urgent you can use apt-get clean in order to free up more space. this command will have the software installed .deb package file be deleted. in most cases, you will not use these .debs files, so if you disk space lack of feel bruised and battered, this approach might be worth a try)

    【aptitude autoclean】

9) apt-get clean installation of the backup software is also removed, but this does not affect the use of the software

    【aptitude clean】

2, apt-cache

        apt-cache - query the APT cach.

        apt-cache performs a variety of operations on APT's package cache.  apt-cache does not manipulate the state of the system but does provide operations to search and generate interesting output from the package metadata.

1) apt-cache depends packagename about using dependence

2) apt-cache rdepends packagename is a view which packages the packet is dependent

3) apt-cache search packagename search packet

    【aptitude search packagename】

4) apt-cache show packagename   acquired package information, as described, the size, version, etc.

    【aptitude show packagename】

5) apt-cache showpkg packagename shows the approximate information package

(Note: in brackets [] in the aptitude is a package similar to apt- * of upper management tool)

reference:

Ali cloud open mirror sites: http://mirrors.aliyun.com/

YORK open mirror sites: http://mirrors.163.com/

书籍:《The Linux Command Line》William E. Shotts, Jr.

Ubuntu official website: https://www.ubuntu.com

Debian official website: https://www.debian.org/doc/user-manuals

https://www.debian.org/doc/manuals/debian-handbook/apt.zh-cn.html

Lost personal blog: http://blog.csdn.net/astraylinux/article/details/7039744

Guess you like

Origin www.cnblogs.com/xuanbjut/p/12625748.html