web123456

Installation Uninstallation and Removal Methods in Ubuntu

Note: Since the GUI methods (such as Add/Remove... and Synaptic Package Manageer) are relatively simple, we summarize here the methods of installing, uninstalling and removing packages from the command line in the terminal.

I. Software Installation Methods in Ubuntu

1. APT method

(1) Ordinary installation: apt-get install softname1 softname2 ...;

(2)Repair Installation:apt-get -f install softname1 softname2... ;(-f Atemp to correct brokendependencies)

(3) Reinstall: apt-get --reinstall install softname1 softname2... ;

2、Dpkg way

(1) Normal installation: dpkg -i package_name.deb

3. Source code installation (.tar,, tar.bz2,)

First unzip the source tarball and then pass thetar commandto accomplish

a. Solution: tar zxf
b. Solution: tar zxf
c. Solution: tar zxf
d. Unzip xx.bz2: bunzip2 xx.bz2
e. Solution: tar xf

Then go to the extracted directory, and it is recommended to read the README or something like that first, because at this point different source code packages orpre-compileThe packages may differ, and it is then recommended to take a look at the executable using the ls -F --color or ls -F commands (actually, mine only needed the l command), which will be marked with a * at the end of the executable.

Generally execute . /configure

                      make

                     sudo make install

The installation can be completed.

Second, the uninstallation method of software packages in Ubuntu

1. APT method

(1) Removal uninstallation: apt-get remove softname1 softname2 ...; (remove the package, when there is a + at the end of the package, it means install)

(2) Purge uninstall : apt-get --purge remove softname1 softname2... ;(also clear the configuration)

Clear uninstall: apt-get purge sofname1 softname2... ;(same as above, also clears configuration files)

2、Dpkg way

(1) Removal uninstallation: dpkg -r pkg1 pkg2 ... ;

(2) Clear uninstallation: dpkg -P pkg1 pkg2... ;) ;

Package lookup method in Ubuntu

Dpkg uses text files as databases. It is commonly referred to as the/var/lib/dpkg directory. Generally, the status file stores software status and control information. The control files are backed up in the info/ directory, and a list of installed files is recorded in the .list file under that directory, and the MD5 encoding of the files is stored in the .mdasums file under that directory.

The time has come to experience the use of databases.

$ 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 entry corresponds to a package, note the first, second, and third characters of each entry. This is the package's status identifier, followed by the package name, version number, and a brief description.

  • The first character is the expected value, which consists of.
    • u The status is unknown, which means that the package is not installed and the user has not sent a request to install it.
    • i User request to install a software package.
    • r User request to uninstall the package.
    • p User request to clear the package.
    • h User request to keep package version locked.
  • The second column is the current state of the package. This column contains the six states of the package.
    • n The package is not installed.
    • i The package is installed and the configuration is completed.
    • c The package was previously installed and now deleted, but its configuration file remains on the system.
    • u The package is unpacked, but not yet configured.
    • f Attempted to configure the package, but failed.
    • h The package was installed, but it did not work.
  • The third column identifies the error status, which can be summarized in four states. The first one identifies that there is no problem and is empty. The other three symbols identify the corresponding problems.
    • h Packages are mandatorily maintained because they cannot be upgraded due to the dependency requirements of other packages.
    • r The software package is corrupted and may need to be reinstalled for normal use (including deletion).
    • x The flexible package is broken and forced to hold.

It is also possible to do a fuzzy query in wildcard mode, e.g. I want to find all packages starting with the nano character.

$ 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 above status indicates that: The system has been installed withnano Versions for1.3.10-2 ; Installednano-tiny , later cleared; never installednanoblogger .

If you feel that dpkg has too many parameters to memorize, you can use dpkg-query to query the dpkg database.

Application examples.

  • To query the system for files belonging to nano.
    $ dpkg --listfiles nano
    or
    $ dpkg-query -L nano
  • View detailed information about the software nano.
    $ dpkg -s nano
    or
    $ dpkg-query -s nano
  • Check the status of packages in the system, support fuzzy query.
    $ dpkg -l
    or
    $dpkg-query -l
  • To view the package to which a file belongs.
    $ dpkg-query -S nano
    or
    $ dpkg -S nano

III. Summary of other applications

apt-cache search # ------(package search package)
apt-cache show #------(package Get information about the package, such as description, size, version, etc.)
apt-get install # ------(package install package)
apt-get install # -----(package --reinstall reinstall package)
apt-get -f install # ----- (force install, "-f = --fix-missing" as fix install...)
apt-get remove #-----(package remove package)
apt-get remove --purge # ------ (package removes packages, including removing configuration files, etc.)
apt-get autoremove --purge # ---- (package removes package and its dependencies + configuration files, etc. (only works for 6.10, highly recommended))
apt-get update #------ update source
apt-get upgrade #------ update installed packages
apt-get dist-upgrade # --------- upgrade system
apt-get dselect-upgrade #------ upgrade with dselect
apt-cache depends #-------(package Understanding usage dependencies)
apt-cache rdepends # ------(package to learn about a specific dependency, as a way to see which packages the package depends on...)
apt-get build-dep # ------ (package installs the relevant build environment)
apt-get source #------(package Download the source code for this package)
apt-get clean && apt-get autoclean # -------- clean archive of downloaded files && clean only obsolete packages
apt-get check #------- check for corrupted dependencies
dpkg -S filename ----- Find which package filename belongs to
apt-file search filename ----- to find which package filename belongs to
apt-file list packagename ----- lists the contents of the package
apt-file update --Update apt-file's database

dpkg --info "package name" -- Lists the unpacked package name.
dpkg -l --Lists all packages on the current system. Can be used with the parameter less for split-screen viewing. (Similar to rpm -qa).
dpkg -l |grep -i "package name" --View the packages associated with "package name" on your system.
dpkg -s Queries the details of installed packages.
dpkg -L queries the location of installed packages on the system. (Similar to rpm -ql)
dpkg -S queries which package a file belongs to on the system. (Similar to rpm -qf)
dpkg -I looks up the details of a deb package to see if it should be installed after a package has been downloaded locally.
dpkg -i manually installs packages (this command does not resolve dependencies before the package), if you encounter a software dependency problem when installing a package, you can use apt-get -f install to resolve the dependency problem.
dpkg -r Uninstallation of softwarePackage. It's not a complete uninstall, its configuration file is still there.
dpkg -P uninstall them all (but still doesn't solve the problem of package dependencies)
dpkg -reconfigure reconfigure


apt-get install
Download the package, and all dependent packages, and install or upgrade the package at the same time. If a package is set to hold, it will be put on hold (i.e. not upgraded). See below for more details on hold.
apt-get remove [--purge]
Remove and any other packages that depend on this package.
The --purge specifies that the package should be purged, see dpkg -P for more information.

apt-get update
Upgrade the list of packages from the Debian mirror, run it at least once a day if you want to install any of the day's software, and every time you modify the
After /etc/apt/, it must be executed.

apt-get upgrade [-u]
Upgrades all installed packages to the latest available version. No new packages will be installed or old packages removed. If a package changes dependencies and a new package needs to be installed, it will not be upgraded and will be marked as hold. apt-get update will not upgrade packages that are marked as hold (which is what hold means). See below for how to set packages to hold manually, I recommend using the '-u' option as well, because then you can see which packages will be upgraded.

apt-get dist-upgrade [-u]
Similar to apt-get upgrade, except that dist-upgrade installs and removes packages to satisfy dependencies. Therefore, it can be dangerous.

apt-cache search
In Package Name and Description, search for packages that contain xxx.

apt-cache show
Displays a complete description of a package.

apt-cache showpkg
Shows more details about the package and how it relates to other packages.

dselect
console-apt
aptitude
gnome-apt
There are several graphical front-ends for APT (some of which have to be installed before you can use them). Here dselect is undoubtedly the most powerful, but also the oldest and most difficult to navigate.

General Dpkg Usage
dpkg -i
Install a Debian package file such as the one you downloaded manually.

dpkg -c
The contents of the list.

dpkg -I
Extracts package information from the

dpkg -r
Removes an installed package.

dpkg -P
Completely removes an installed package. Unlike remove, which only removes data and executables, purge additionally removes all configuration files.

dpkg -L
Make a list of all files installed. Also see dpkg -c to examine the contents of a .deb file.

dpkg -s
Displays information about installed packages. See also apt-cache to display information about packages in the Debian archive, and dpkg -I to display information about packages extracted from a .deb file.

dpkg-reconfigure
Reformatting an installed package if it uses debconf (debconf provides a unified formulation interface for package installation). You can reformat debconf itself if you want to change its frontend or prioritize questions. For example, reformatting debconf to use a dialog front-end is easy to do:

dpkg-reconfigure --frontend=dialog debconf (if you made a mistake when installing, you can change it back here :))

echo " hold" | dpkg --set-selections
Set the state of hlod (command line mode)

dpkg --get-selections ""
The current state of the fetch (command line mode)

Wildcards are supported, e.g:
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

Example:
Everyone is using gaim-0.58 + QQ-plugin, in order to prevent gaim from being upgraded, we can use the following method:

Method I:
Debian:~# echo "gaim hold" | dpkg --set-selections
Then check it with the following command:
Debian:~# dpkg --get-selections "gaim"
gaim hold
Now that the status flag is hold, it cannot be upgraded.

What if I want to recover?
Debian:~# echo "gaim install" | dpkg --set-selections
Debian:~# dpkg --get-selections "gaim"
gaim install
At this point the status flag is reset to install again and the upgrade can continue.

Comrades will ask, which all these status flags are written in which file?
You can also implement hold in /var/lib/dpkg/status by modifying this file.

Sometimes you will find software with a status flag of purge, don't be surprised.
E.g. you have already installed amsn and uninstalled it.
apt-get remove --purge amsn
Then the status flag changes from install to purge.

Method II:
Manually create a preferences file under /etc/apt.
Content:
Package: gaim
Pin: version 0.58*
save (a file etc) (computing)

dpkg -S
Looks up in the package database , and tells you which package contains the file. (Note: the search is for pre-installed packages)

--------------------------------------------
Incomplete list of commands for Debian's package management tools
--------------------------------------------
All package information on a Debian system is located in /var/lib/dpkg. The /var/lib/dpkg/info directory contains package information and administrative files. Each file has the following functions.
Files ending in ".conffiles" record the configuration list of the package.
Files ending with ".list" contain a list of package files where you can find out where they are installed.
Files ending in ".md5sums" record md5 information and are used for package authentication.
Files ending in ".config" are the installation configuration corner of the package.
The ".postinst" corner is used to complete the configuration of Debian packages after they have been unpacked, and is usually used to execute commands related to the installed packages and to restart services.
The ".preinst" script is run before Debain unpacks the package, the main purpose of which is to stop the services of the upgraded package until the installation or upgrade of the package is complete.
The ".prerm" script is responsible for stopping the daemon service associated with the package, and is executed before deleting the package's associated files.
The ".postrm" script is responsible for modifying package links or file associations, or deleting files created by it.

/var/lib/dpkg/available is the package description.
Includes all packages from the Debian installation sources used on the current system, and also includes installed and uninstalled packages on the current system.
          
Package Management Tools

dpkg -r uninstalls the package. This is not a complete uninstall, its configuration file is still there.
dpkg --info "package name" -- Lists the unpacked package name.
dpkg -l --Lists all packages on the current system. Can be used with the parameter less for split-screen viewing.
dpkg -l |grep -i "package name" --View the packages associated with "package name" on your system.
dpkg -s Queries the details of an installed package. dpkg -L Queries the location of installed packages on the system.
dpkg -S queries which package a file belongs to on the system.
dpkg -I looks up the details of a deb package to see if it should be installed after a package has been downloaded locally.
dpkg -i manually installs packages (this command does not resolve dependencies before the package), if you encounter a software dependency problem when installing a package, you can use apt-get -f install to resolve the dependency problem.
dpkg -reconfigure reconfigure
dpkg -P uninstall them all (but still doesn't solve the problem of package dependencies)


2. apt advanced package management tool
(1) GTK graphics "synaptic", which is APT's front-end tool.
(2) "aptitude", which is also the front-end tool of APT.
Using APT management tools for package management, there can be several ways to do the source.
(1) Take the installation disk as the source, the method is as follows.
apt-cdrom ident Scanning for information on CD-ROMs
apt-cdrom add Adding a CD-ROM source
(2) This is also the most common method is to add the source to /etc/apt/, and then update the apt-get update column.


APT management tool common commands
apt-cache can be used with different subcommands and parameters to find and display software, package information and package dependencies.
apt-cache stats Displays statistics for all Debain data sources currently in use on the system.
apt-cache search + "package name", you can find related packages.
apt-cache show +"package name", you can display the details of the specified package.
apt-cache depends + "package name" to find package dependencies.
apt-get upgrade Updates all packages on the system to the latest version
apt-get install installs the package
apt-get --reindtall install reinstall package
apt-get remove Uninstall the package
apt-get --purge remove uninstalls the package completely
apt-get clean removes useless packages
Before installing packages with apt-get install, the packages are downloaded to /var/cache/apt/archives and then installed. So we can use apt-get clean to remove the packages from the /var/cache/apt/archives directory.


Source Package Installation
apt-cache showsrc Find information about the files that look at the source package (before downloading)
apt-get source Download the source package.
apt-get build-dep +"package name" Builds the build environment for the source package.

Remove packages in rc state

dpkg -l |grep ^rc|awk '{print $2}' |tr ["\n"] [" "] | sudo xargs dpkg -P -