APT is more than apt-Get.
In ubuntu (Debian), installing software with APT-Get or synaptic is very easy. In addition to simple installation software, APT tool set has many usage in special cases.
Remember that the man manual is a mentor at any time.
1. Use aptitude instead of APT-Get.
Although aptitude does not have the "Super Awesome" feature of APT-get, it is more powerful than apt-Get.
First, you can install software like apt-Get.
Code: |
Aptitude install pack-foo |
Aptitude is more intelligent in solving dependencies than apt-Get. Sometimes, when you use apt-get to install software, "XXX requires XXXX, But xxx
"This type of error has been installed. This is usually caused by some new software packages. When aptitude is used, aptitude will discover the problem and provide several solutions,
We only need to accept the right solution.
Another advantage of aptitude is that it will automatically record the packages that are "automatically installed" (that is, those installed due to dependency). If the packages that depend on the "automatically installed" package are not installed, the "automatic installation" Package (useless at this time) will be automatically deleted.
You can use these two commands to control the "Automatic Installation" attribute of the package.
Code: |
Aptitude markauto pack-Foo # mark as "automatic installation" Aptitude unmarkauto pack-Foo # mark as "manual installation" |
When you delete software, use markauto instead of remove to avoid accidental deletion of important packages.
Of course, the new version and apt-Get have similar functions, but it does not seem to use the same database as aptitude. Therefore, we recommend that you only use the aptitude management package.
Aptitude also provides a more flexible way to control the software package version.
Code: |
Hold-keep the Software Package Unhold-cancel the hold command for a software package Forbid-version-Disable aptitude from being upgraded to a specific version of the software package. |
The libcairo event of the previous weeks is used as an example:
Code: |
Sudo aptitude install libcairo2 = 1.4.10-1ubuntu4 # force downgrade Sudo aptitude forbid-version libcairo2 = 1.4.10-1ubuntu4. 1 # disable the version with an error Sudo aptitude markauto libcairo2 # restore the auto attribute |
See the description of the install operation in the man manual for more control methods.
Aptitude reinstall the software package, which is equivalent to Apt-Get -- reinstall install
Aptitude purge deletes the software package completely, which is equivalent to Apt-Get -- purge remove.
Tips
Code: |
Aptitude purge 'dpkg-L | grep' ^ RC '| awk' {print $2 }'' |
Aptitude also integrates the functions of multiple apt tools
Code: |
Search-search for software packages by name and/or expression Show-displays the details of a software package. Download-download the. Deb file of the software package |
The search operation is special.
Code: |
APTITUDE search "foo bar" # Keys Foo and bar must appear APTITUDE search Foo bar # equivalent to "or" |
However, aptitude has a small disadvantage. By default, the "recommended" package will be treated as a "dependent" package. In this way, you can solve the problem by setting it.
Add a sentence to the. Aptitude/config file in the home directory of the user and the root user.
Code: |
Aptitude: recommends-important "false "; |
For more detailed usage, see man aptitude.
In addition:
1. The interaction mode of aptitude seems to be messy. It is better to use the new mode.
2. Use aptitude install-F with caution.
2. Obtain
Simple
Use a new version:
1. Select the package to be installed
2. File-> Generate the package download script
Use apt-Get
Code: |
Apt-Get -- print-Uris install pack-foo |
3. Install the required package
First, make sure you have added the Deb-SRC Source, just like this
Code: |
Deb-Src http://ubuntu.cn99.com/ubuntu/ gutsy main restricted universe multiverse |
And has apt-Get update
Then you can
Code: |
Apt-Get build-dep pack-foo |
Install the package required for compiling pack-foo
PS: the more powerful method is to use apt-build. However, Ubuntu is too much like Gentoo. If you are interested, you can check the man of APT-build on your own.
4. Find the package in which a file is located.
If the package is installed, you can use dpkg-s, but this method does not work for uninstalled packages.
Now you can use apt-File
Code: |
$ Apt-file help Apt-file version 2.0.8.2 (C) 2002 Sebastien J. Gross <sjg@debian.org> Apt-file [Options] action [pattern] Configuration Options: -- Sources-list-S <File> sources. List location -- Cache-C <dir> cache directory -- Architecture-A <arch> use specific architecture -- CDROM-mount-D <CDROM> use specific CDROM mountpoint -- Package-only-l only display packages name -- Fixed-string-F do not expand pattern -- Ignore-case-I ignore case distinctions -- Regexp-x pattern is a regular expression -- Verbose-V run in Verbose Mode -- Dummy-y run in dummy mode (no action) -- Help-H show this help. -- Version-V show version number Action: Update fetch contents files from APT-sources. Search | find <pattern> Search files in packages List | show <pattern> List Files in packages Purge remove cache files |
This tool is useful when looking for files missing during compilation. Remember to use apt-file update before using it.
PS: auto-APT has the same function and can detect the missing files required by the process. It automatically prompts the user to choose to install the corresponding package.