Summary of software installation, uninstallation and viewing methods in Ubuntu

Source: Internet
Author: User

Note: graphic interface methods (such as Add/Remove... and Synaptic Package manageer) is relatively simple, so here we mainly summarize the methods for installing, detaching, and deleting software packages on the terminal through the command line method.

1. Install software in Ubuntu

1. APT Mode

(1) General installation: APT-Get install softname1 softname2 ...;

(2) fix and install: APT-get-F install softname1 softname2.... (-F atemp to correct broken dependencies)

(3) reinstall: APT-Get -- reinstall install softname1 softname2 ...;

2. dpkg Mode

(1) General installation: dpkg-I package_name.deb

3、source code installation (.tarw.tar.gz?tar.bz2, tar. Z)

Decompress the source code package and run the tar command.

A. xx.tar.gz: Tar zxf xx.tar.gz
B. xx.tar. Z: Tar zxf xx.tar. Z
C. Solution XX. tgz: Tar zxf XX. tgz
D. xx.bz2: bunzip2 xx.bz2
E. xx.tar: tar xf xx.tar

Then go to the decompressed directory. We recommend that you read the instructions files such as readme first, because there may be differences between different source code packages or pre-compiled packages, we recommend that you use the LS-f -- color or LS-F command (in fact, I only need the l command) to view the executable file. The executable file will be marked with the tail sign.

Execute./configure in sequence.

Make

Sudo make install

To complete the installation.

Ii. How to uninstall the software package in Ubuntu

1. APT Mode

(1) detachable upon removal: APT-Get remove softname1 softname2 ...; (Remove the software package. When + exists at the end of the package, it indicates installation)

(2) Clear uninstall: APT-Get -- purge remove softname1 softname2. .. (clear configuration at the same time)

Clear uninstall: APT-Get purge sofname1 softname2. .. (same as above, also clear the configuration file)

2. dpkg Mode

(1) detachable: dpkg-r pkg1 pkg2 ...;

(2) Cleanup unload: dpkg-P pkg1 pkg2 ...;

 

Iii. query methods of software packages in Ubuntu

Dpkg uses text files as databases./var/lib/dpkg
Directory. the general name stores the software status and control information in the status file. back up the control file in the info/directory and. the list file records the list of installation files, under which. mdasums stores the MD5 code of the file.

It's time to experience using the database:

$ dpkg -l
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-===========-================-========================================
ii aalib1 1.4p5-28 ascii art library - transitional package
ii adduser 3.85 Add and remove users and groups
ii alien .63 install non-native packages with dpkg
... ...


Each record corresponds to a software package. Note the first, second, and third characters of each record. This is the status identification of the software package, followed by the software package name, version number, and simple description.

  • The first character is the expected value, which includes:

    • The U status is unknown, which means that the software package is not installed and the user has not sent an installation request.
    • I. the user requested to install the software package.
    • R user requests to uninstall the software package.
    • P user request to clear the software package.
    • H. The user requests to keep the software package version locked.
  • The second column is the current status of the software package. This column includes six States of the software package.

    • N software package not installed.
    • Install the I software package and complete the configuration.
    • The C package has been installed before and is deleted, but its configuration file remains in the system.
    • The U software package is unwrapped, but not configured yet.
    • F tried to configure the software package, but failed.
    • H software package installation, but not successful.
  • The third column identifies the error status, which can be summarized as four states. The first type of status identity is normal and empty. The other three symbols identify the problem.

    • The H software package is forcibly maintained because it cannot be upgraded due to dependency requirements of other software packages.
    • The r package is damaged and may need to be re-installed for normal use (including deletion ).
    • X soft package is damaged and forcibly maintained.

You can also perform fuzzy search in the unified character mode. For example, I want to find all the software packages starting with nano:

$ dpkg -l nano*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-==============-============================================
ii nano 1.3.10-2 free Pico clone with some new features
pn nano-tiny <none> (no description available)



un nanoblogger <none> (no description available)


The preceding status description is installed in the system.nano
Version:1.3.10-2
; Installednano-tiny
, And then cleared; never installednanoblogger
.

If you think that too many dpkg parameters are difficult to remember, you can use dpkg-query to query the dpkg database.

Example:

  • Nano files in the query system:

    $ Dpkg -- listfiles nano

    Or

    $ Dpkg-query-L NaNO

  • View the software nano details:

    $ Dpkg-s nano

    Or

    $ Dpkg-query-s nano

  • Check the status of software packages in the system. Fuzzy search is supported:

    $ Dpkg-l

    Or

    $ Dpkg-query-l

  • View the owner package of a file:

    $ Dpkg-query-s nano

    Or

    $ Dpkg-s nano

Iii. Summary of other applications

Apt-cache search # ------ (package search package)
Apt-Cache show # ------ (package obtains package information, such as description, size, and Version)
Apt-Get install # ------ (package installation package)
Apt-Get install # ----- (package -- reinstall re-installation package)
Apt-get-F install # ----- (Force installation, "-F = -- fix-missing" should be fixed and installed ...)
Apt-Get remove # ----- (delete package)
Apt-Get remove -- purge # ------ (package deletes a package, including deleting a configuration file)
Apt-Get autoremove -- purge # ---- (package deletes packages and their dependent packages + configuration files (only valid for 6.10, it is strongly recommended ))
Apt-Get update # ------ update source
Apt-Get upgrade # ------ Update installed packages
Apt-Get dist-upgrade # --------- upgrade the system
Apt-Get dselect-upgrade # ------ upgrade with dselect
Apt-Cache depends # ------- (package knows how to use dependencies)
Apt-Cache rdepends # ------ (package understands a specific dependency. Check which packages depend on this package ...)
Apt-Get build-dep # ------ (package installation-related compilation environment)
Apt-Get source # ------ (package downloads the source code of the package)
Apt-Get Clean & apt-Get autoclean # -------- clear the archive of downloaded files & only clear outdated packages
Apt-Get check # ------- check for corrupted Dependencies
Dpkg-s filename ----- find the software package of filename
Apt-file search filename ----- find the software package of filename
Apt-file list packagename ----- List the content of a software package
Apt-file update -- Update apt-file database

Dpkg -- info "package name" -- list the package names after the package is unwrapped.
Dpkg-l -- list all packages in the current system. You can use it with the parameter less in the split screen view. (similar to rpm-Qa)
Dpkg-L | grep-I "package name" -- view the packages associated with "package name" in the system.
Dpkg-S: query the details of installed packages.
Where the installed software package is installed in the dpkg-l Query System (similar to rpm-QL)
Which package does dpkg-s query system belong to a file? (similar to rpm-QF)
Dpkg-I queries the detailed information of the Deb package. After downloading a software package to a local computer, check whether it is installed ).
Dpkg-I install the software package manually (this command does not solve the dependency problem before the Software Package). If you encounter software dependency problems when installing a software package, you can use apt-get-F install to solve the reliability problem.
Dpkg-r uninstall the software package. The configuration file does not exist.
Dpkg-P all unmount (but it still cannot solve the dependency problem of the software package)
Dpkg-reconfigure Reconfiguration

Apt-Get install
Download the software package and all dependent packages, and install or upgrade the package at the same time. If a package is set to hold (stop flag, it will be put aside (that is, it will not be upgraded ). For more information about hold, see the following.
Apt-Get remove [-- purge]
Remove and any other packages dependent on this package.
-- Purge indicates that the package should be completely purged (purged). For more information, see dpkg-P.

Apt-Get update
Upgrade the package list from the Debian image. If you want to install any software on the current day, run the package at least once a day and modify the package every time.
/Etc/APT/sources. list must be executed.

Apt-Get upgrade [-u]
Upgrade all installed packages to the latest available version. Old packages will not be installed or removed. If a package needs to install a new package because it has changed its dependency, it will not be upgraded, but marked
Hold. Apt-Get update will not upgrade the package marked as "hold" (this is what "hold" means ). See how to manually set the package
Hold. We recommend that you use the '-U' option at the same time, because you can see which packages will be upgraded.

Apt-Get dist-upgrade [-u]
Similar to Apt-Get upgrade, apart from dist-upgrade, packages are installed and removed to satisfy the dependency. Therefore, it is dangerous.

Apt-cache search
In the package name and description, search for the package containing XXX.

Apt-Cache show
Displays the complete description of a software package.

Apt-Cache showpkg
Show more details about the software package and its relationship with other packages.

Dselect
Console-Apt
Aptitude
Gnome-Apt
Several graphical front ends of APT (some of which must be installed before use ). Here, dselect is undoubtedly the most powerful, the oldest, and the most difficult to control.

Common dpkg usage
Dpkg-I
Install a Debian package file, such as the file you downloaded manually.

Dpkg-C
List content.

Dpkg-I
Extract package information from.

Dpkg-R
Remove an installed package.

Dpkg-P
Completely clear an installed package. Unlike remove, remove only deletes data and executable files, and purge also deletes all preparation files.

Dpkg-l
List all installed files. Check the content of A. Deb file by checking dpkg-C.

Dpkg-S
Displays information about the installed packages. At the same time, check that APT-Cache displays the package information in the Debian archive and dpkg-I to display the package information extracted from a. Deb file.

Dpkg-reconfigure
Re-create an installed package if debconf is used (debconf provides a unified configuration interface for package installation ). You can reconfigure
Debconf itself, if you want to change the priority of its front-end or question. For example, re-prepare debconf and use a dialog front-end for simple operation:

Dpkg-reconfigure -- frontend = dialog debconf (if you have chosen an error during installation, you can change it back here :)

Echo "hold" | dpkg -- Set-selections
Set the status to hlevels (command line)

Dpkg -- Get-selections ""
The current status (in command line mode)

Wildcard characters are supported, such:
Debian :~ # Dpkg -- Get-selections * wine *
Libwine hold
Libwine-ALSA hold
Libwine-arts hold
Libwine-dev hold
Libwine-Nas hold
Libwine-print hold
Libwine-Twain hold
Wine hold
Wine + hold
Wine-Doc hold
Wine-utils hold

For example:
We are using gaim-0.58 + QQ-plugin, in order to prevent Gaim from being upgraded, we can use the following method:

Method 1:
Debian :~ # Echo "Gaim hold" | dpkg -- Set-selections
Then run the following command to check:
Debian :~ # Dpkg -- Get-selections "Gaim"
Gaim hold
The Current Status indicates "hold" and cannot be upgraded.

What should I do if I want to restore it?
Debian :~ # Echo "Gaim install" | dpkg -- Set-selections
Debian :~ # Dpkg -- Get-selections "Gaim"
Gaim install
At this time, the status flag is reset to install again, and the upgrade can continue.

Comrades will ask, which of these status signs are written in which file?
In/var/lib/dpkg/status, you can also modify this file to implement hold.

Sometimes you will find that some software status signs are purge, don't be surprised.
For example, amsn has been installed in advance, and then it is unloaded.
Apt-Get remove -- purge amsn
Then the status flag changes from install to purge.

Method 2:
Manually create a preferences file under/etc/Apt
Content:
Package: Gaim
Pin: Version 0.58 *
Save

Dpkg-S
Find the package in the database and tell you which package contains the file. (Note: Find the packages that have been installed in advance)

--------------------------------------------
Incomplete command list of Debian software package management tools
--------------------------------------------
All the package information in the Debian system is under/var/lib/dpkg. the/var/lib/dpkg/info directory stores the Information and Management Files of each software package. each file has the following functions:
The configuration list of the file recording package ending with ". conffiles.
The file ending with ". List" records the file list of the software package. You can find the specific installation location of the software package file in the file.
The file ending with ". md5sums" records the MD5 information for packet verification.
The file ending with ". config" is the installation configuration angular of the software package.
The ". postinst" section is used to complete the configuration after the Debian package is unbound. It is usually used to execute commands related to the Installed Package and restart the service.
Run the ". preinst" command before debain unpacks. The main function is to stop the software package services that will be upgraded until the software package is installed or upgraded.
The ". prerm" script is used to stop the daemon service associated with the software package and run it before deleting the software package associated file.
The ". postrm" script is used to modify the software package link or file association, or delete the files created by it.

/Var/lib/dpkg/available is the description of the software package.
Includes all the software packages in the Debian installation source used in the current system, as well as the software packages that have been installed and not installed in the current system.

1. dpkg package management tool

Dpkg-r uninstall the software package. The configuration file does not exist.
Dpkg -- info "package name" -- list the package names after the package is unwrapped.
Dpkg-l -- list all packages in the current system. You can use it with the parameter less in the split screen view.
Dpkg-L | grep-I "package name" -- view the packages associated with "package name" in the system.
Dpkg-s query the detailed information of the installed package. The position of the installed software package in the dpkg-l query system.
Which package does dpkg-s query system belong to a file.
Dpkg-I queries the detailed information of the Deb package. After downloading a software package to a local computer, check whether it is installed ).
Dpkg-I install the software package manually (this command does not solve the dependency problem before the Software Package). If you encounter software dependency problems when installing a software package, you can use apt-get-F install to solve the reliability problem.
Dpkg-reconfigure Reconfiguration
Dpkg-P all unmount (but it still cannot solve the dependency problem of the software package)

 


2. APT advanced package management tools
(1) "synaptic" of GTK graphics, which is the front-end tool of apt.
(2) "aptitude", which is also the front-end tool of apt.
You can use the apt management tool to manage packages by using the following methods:
(1) Use the installation disk as the source. The method is as follows:
Apt-CDROM ident scan information of the disc
Apt-CDROM Add add a CD Source
(2) The most common method is to add the source to/etc/APT/source. list, and then update the apt-Get Update column.


Common commands of APT management tools
Apt-Cache can be used with different sub-commands and parameters to find and display software, package information, and package trust relationships.
Apt-Cache stats displays statistics of all the debain data sources used by the current system.
Apt-cache search + "package name" to find related software packages.
Apt-Cache show + "package name" to display the details of the specified software package.
Apt-Cache depends + "package name", you can find the dependency of the software package.
Apt-Get upgrade: update all packages in the system to the latest version.
Apt-Get install installation package
Apt-Get -- reindtall install reinstall the Software Package
Apt-Get remove uninstall software package
Apt-Get -- purge remove uninstall software package completely
Apt-Get clean clear useless software packages
Before using the command apt-Get install, download the software package to/var/Cache/APT/archives and then install it. so we can use apt-Get clean to clear software packages in the/var/Cache/APT/archives directory.


Source code package installation
Apt-Cache showsrc: Find the file information of the source package (before download)
Apt-Get source to download the source package.
Apt-Get build-dep + "package name" build the compiling environment of the source package.

 

Clear software packages in RC status

Dpkg-L | grep ^ RC | awk '{print $2}' | tr ["/N"] [""] | sudo xargs dpkg-p-

Related Article

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.