How to add or delete software in Ubuntu

1. How to install software in Ubuntu
1. APT method
(1) Normal installation: apt-get install softname1 softname2 ...;
(2)修复安装:apt-get -f install softname1 softname2... ;(-f Atemp to correct broken dependencies)
(3) Reinstall: apt-get --reinstall install softname1 softname2...;
2. Dpkg method
(1) Normal installation: dpkg -i package_name.deb
3. Source installation (.tar, tar.gz, tar.bz2, tar.Z)
First unzip the source tarball and then do it with the tar command
a.解xx.tar.gz:tar zxf xx.tar.gz 
b.解xx.tar.Z:tar zxf xx.tar.Z 
c.解xx.tgz:tar zxf xx.tgz 
d. Solution xx.bz2: bunzip2 xx.bz2 
e.解xx.tar:tar xf xx.tar
Then enter the decompressed directory. It is recommended to read the README and other instructions first, because there may be differences between different source code packages or precompiled packages, and then it is recommended to use the ls -F --color or ls -F command ( In fact, mine only needs the l command) Check the executable file, the executable file will be marked with a * at the end.
Generally, execute ./configure in sequence
                      make
                     sudo make install
Installation is complete.
2. How to uninstall packages in Ubuntu
1. APT method
(1) Removal uninstall: apt-get remove softname1 softname2 ...; (remove a package, when there is a + at the end of the package, it means installation)
(2) Purge uninstall: apt-get --purge remove softname1 softname2...; (clear the configuration at the same time)
        Clear uninstall: apt-get purge sofname1 softname2...; (same as above, also clear the configuration file)
2. Dpkg method
(1) Removable unloading: dpkg -r pkg1 pkg2 ...;
(2) Clear unloading: dpkg -P pkg1 pkg2...;
 
Third, the query method of software packages in Ubuntu
Dpkg uses text files as a database . It is generally called in the /var/lib/dpkg directory. It is generally called in the status file to store software status and control information. Backup the control file in the info/ directory, and in the .list file under it Record the list of installation files, under which .mdasums saves the MD5 encoding of the files.
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 package, pay attention to the first, second, and third characters of each record. This is the status identifier of the package, followed by the package name, version number, and brief description.
The first character is the expected value, which includes:
The u status is unknown, which means the package is not installed and the user has not made an install request.
i User requests to install a package.
r The user requested to uninstall the package.
p User requested to clear the package.
h User request to keep package version locked.
The second column, is the current state of the package. This column includes the six states of the package.
n package is not installed.
The i package is installed and configured.
The c package was previously installed and is now removed, but its configuration file remains on the system.
The u package is unpacked, but not yet configured.
f tried to configure the package, but failed.
h package is installed, but without success.
The third column identifies the error state, which can be summarized into four states. The first state identifies no problem and is empty. The other three symbols identify the corresponding problem.
The h package is forced to remain, and cannot be upgraded because of other package dependencies.
The r package is broken and may need to be reinstalled for normal use (including removal).
The x package is broken and forced to remain.
It is also possible to do fuzzy queries in wildcard mode, for example I want to find all packages starting with nano characters:
$ 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 state description: The nano version is 1.3.10-2 installed in the system; nano-tiny was installed, and then cleared; nanoblogger was never installed.
If you feel that the parameters of dpkg are too many, it is not conducive to memory, you can use dpkg-query to query the dpkg database.
Application example:
Query the files belonging to nano in the system:
$ dpkg --listfiles nano
or
$ dpkg-query -L nano
Check out the details of the software nano:
$ dpkg -s nano
or
$ dpkg-query -s nano
View the status of software packages in the system, support fuzzy query:
$ dpkg -l
or
$dpkg-query -l
Check the belonging package of a file:
$ dpkg-query -S nano
or
$ dpkg -S nano
3. Summary of other applications
apt-cache search # ------(package search package)
apt-cache show #------(package gets information about the package, such as description, size, version, etc.)
apt-get install # ------(package installation package)
apt-get install # -----(package --reinstall reinstalls the package)
apt-get -f install # -----(Force installation, "-f = --fix-missing" is a repair installation...)
apt-get remove #-----(package delete package)
apt-get remove --purge # ------(package removes packages, including removing configuration files, etc.)
apt-get autoremove --purge # ----(package delete package and its dependent packages + configuration files, etc. (only valid for 6.10, strongly recommended))
apt-get update #------ update source
apt-get upgrade #------ update installed packages
apt-get dist-upgrade # --------- upgrade system
apt-get dselect-upgrade #------ use dselect to upgrade
apt-cache depends #-------(package understands using dependencies)
apt-cache rdepends # ------(package understands a specific dependency, when it is to check which packages the package depends on...)
apt-get build-dep # ------(package installation related compilation environment)
apt-get source #------(package download the source code of the package)
apt-get clean && apt-get autoclean # -------- clean archive of downloaded files && only clean outdated packages
apt-get check #------- check for broken dependencies
dpkg -S filename ----- Find which package filename belongs to
apt-file search filename ----- Find which package filename belongs to
apt-file list packagename ----- list the contents of the package
apt-file update -- update the apt-file database
 
dpkg --info "package name" -- List the unpacked package name of the package.
dpkg -l -- list all packages in the current system. Can be used with the parameter less to view in split screen. (similar to rpm -qa)
dpkg -l |grep -i "package name" -- view the packages associated with "package name" in the system.
dpkg -s Query installed package details.
dpkg -L queries the system where installed packages are installed. (similar to rpm -ql)
dpkg -S Query which package a file belongs to in the system. (similar to rpm -qf)
dpkg -I Query the detailed information of the deb package, after a package is downloaded to the local, check whether it is installed or not (take a look).
dpkg -i Manually install the package (this command does not solve the dependency problem before the package), if you encounter a software dependency problem when installing a certain package, you can use apt-get -f install to solve the reliability problem this problem.
dpkg -r uninstalls the package. It is not a complete uninstall, its configuration file still exists.
dpkg -P uninstall all (but still can'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 has a hold (stop flag) set, it will be set aside (i.e. will not be upgraded). See below for more details on hold.
apt-get remove [--purge]
Remove and any other packages that depend on this package.
--purge specifies that the package should be completely purged, see dpkg -P for more information.
 
apt-get update
Update the package list from the Debian mirror, if you want to install any software of the day, run it at least once a day, and every time you modify it
/etc/apt/sources.list must be executed.
 
apt-get upgrade [-u]
Upgrade all installed packages to the latest available versions. Does not install new or remove old packages. If a package changes dependencies and needs to install a new package, it will not be upgraded, but will be marked as hold. apt-get update will not upgrade packages marked as hold (this is what hold means). See below how to manually set a package to hold. 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 dist-upgrade installs and removes packages to satisfy dependencies. Therefore, there is a certain risk.
 
apt-cache search
In Package Name and Description, search for packages containing xxx.
 
apt-cache show
Displays the full description of a package.
 
apt-cache showpkg
Shows more details about the package and its relationship to other packages.
 
dselect
console-apt
aptitude
gnome-apt
Several graphical frontends for APT (some of which must be installed before use). Here dselect is undoubtedly the most powerful, also the oldest, and the most difficult to control.
 
Common Dpkg usage
dpkg -i
Install a Debian package file, such as the one you downloaded manually.
 
dpkg -c
listed content.
 
dpkg -I
Extract package information from it.
 
dpkg -r
Remove an installed package.
 
dpkg -P
Completely remove an installed package. Unlike remove, which just deletes data and executable files, purge also deletes all configuration files.
 
dpkg -L
List all files installed. Also see dpkg -c to check the contents of a .deb file.
 
dpkg -s
Displays information about installed packages. Also see apt-cache to display package information in a Debian archive, and dpkg -I to display package information extracted from a .deb file.
 
dpkg-reconfigure
Reconfigure an installed package if it uses debconf (debconf provides a unified configuration interface for package installation). You can reconfigure the debconf itself, if you want to change its frontend or priority of questions. For example, to reconfigure debconf to use a dialog frontend, simply run:
 
dpkg-reconfigure --frontend=dialog debconf (if you made a mistake during installation, you can change it back here:)
 
echo " hold" | dpkg --set-selections
The set state is hlod (command line mode)
 
dpkg --get-selections ""
The current state of the fetch (command line mode)
 
Wildcards are supported, such as:
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
 
E.g:
Everyone is using gaim-0.58 + QQ-plugin now. In order to prevent gaim from being upgraded, we can use the following methods:
 
method one:
Debian:~# echo "gaim hold" | dpkg --set-selections
Then check it with the following command:
Debian:~# dpkg --get-selections "gaim"
gaim hold
The current status flag is hold, so 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 time, the status flag is reset to install again, and the upgrade can continue.
 
Comrades will ask, in which file are these status flags written?
You can also implement hold by modifying this file in /var/lib/dpkg/status.
 
Sometimes you will find that some software status signs are purge, don't be surprised.
Such as: amsn has been installed in advance, and then uninstall it.
apt-get remove --purge amsn
Then the status flag changes from install to purge.
 
Method Two:
Manually create a preferences file under /etc/apt
content:
Package: gaim
Pin: version 0.58*
keep
 
dpkg -S
Look in the package database and tell you which package contains this file. (Note: The search is for packages that have been installed in advance)
 
--------------------------------------------
Incomplete list of Debian package management tool commands
--------------------------------------------
All package information in the Debian system is under /var/lib/dpkg. The /var/lib/dpkg/info directory saves the information and management files of each package. The functions of each file are as follows:
A file ending in ".conffiles" records the configuration list of the package.
The file ending with ".list" records the file list of the package, and the user can find the specific installation location of the package file in the file.
Files ending with ".md5sums" record md5 information for packet verification.
A file ending in ".config" is the package's installation configuration script.
The ".postinst" script is used to complete the configuration work after the Debian package is unpacked, and is usually used to execute commands related to the installed package and restart services.
The ".preinst" script is run before debain is unpacked, and the main function is to stop the service of the package that is about to be upgraded until the package installation or upgrade is complete.
The ".prerm" script is responsible for stopping the daemon service associated with the package, before removing 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 description of the package.
It includes all the packages in all the Debian installation sources used in the current system, as well as the packages that have been installed and not installed in the current system.
          
1. dpkg package management tool
dpkg -r uninstalls the package. It is not a complete uninstall, its configuration file still exists.
dpkg --info "package name" -- List the unpacked package name of the package.
dpkg -l -- List all packages in the current system. Can be used with the parameter less to view in split screen.
dpkg -l |grep -i "package name" -- view the packages associated with "package name" in the system.
dpkg -s queries installed package details. dpkg -L queries the system where installed packages are installed.
dpkg -S Query which package a file belongs to in the system.
dpkg -I Query the detailed information of the deb package, after a package is downloaded to the local, check whether it is installed or not (take a look).
dpkg -i Manually install the package (this command does not solve the dependency problem before the package), if you encounter a software dependency problem when installing a certain package, you can use apt-get -f install to solve the reliability problem this problem.
dpkg -reconfigure reconfigure 
dpkg -P uninstall all (but still can't solve the problem of package dependencies)
 
 
2. apt advanced package management tool
   (2) "aptitude", which is also the front-end tool of APT.
   There are several ways to manage packages with the APT management tool:
   (1) Take the installation disk as the source, the method is as follows:
        apt-cdrom ident scan disc information
        apt-cdrom add add CD source
   (2) This is also the most common method is to add the source to /etc/apt/source.list, and then update the column apt-get update
 
Common commands of APT management tools
apt-cache plus the use of different subcommands and parameters can achieve functions such as searching, displaying software, package information and package dependencies.
apt-cache stats displays statistics about all Debian data sources used by the current system.
apt-cache search + "package name", you can find related packages.
apt-cache show + "package name", you can display the detailed information of the specified package.
apt-cache depends + "package name", you can find the dependencies of the package.
apt-get upgrade update all packages in the system to the latest version
apt-get install install packages
apt-get --reindtall install reinstall the package
apt-get remove uninstall package
apt-get --purge remove to completely uninstall a package
apt-get clean to remove useless packages
Before using the command apt-get install, the package is first downloaded to /var/cache/apt/archives, and then installed. So we can use apt-get clean to clear the /var/cache/apt/archives directory packages in .
 
Source package installation
   apt-cache showsrc Find file information for viewing source packages (before downloading)
   apt-get source Download source packages.
   apt-get build-dep +"package name" Build the compilation environment of the source package.
 
Clear packages in rc state
dpkg -l |grep ^rc|awk '{print $2}' |tr ["\n"] [" "] | sudo xargs dpkg -P -

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326720897&siteId=291194637