Sudo apt-Get and dpkg commands

Source: Internet
Author: User
I started to learn about Linux today. I searched for some commands on the Internet and reproduced them to facilitate future queries.
-------------------------------------
I. Use of APT (Ubuntu Linux package management tool I)
Apt-cache search # ------ (package search package)
Apt-Cache show # ------ (package obtains package information, such as description, size, and Version)
Sudo apt-Get install # ------ (package installation package)
Sudo apt-Get install # ----- (package--reinstall re-installation package)
Sudo apt-get-F install # ----- (Force installation? # "-F = -- fix-missing"
Install it ...)
Sudo apt-Get remove # ----- (delete package)
Sudo apt-Get remove--Purge # ------ (package deletes a package, including deleting a configuration file
)
Sudo apt-Get autoremove -- purge # ---- (package deletes packages and their dependent packages + configuration files (only valid for 6.10, it is strongly recommended ))
Sudo apt-Get update # ------ update source
Sudo apt-Get upgrade # ------ Update installed packages
Sudo apt-Get dist-upgrade # --------- upgrade the system
Sudo apt-Get dselect-upgrade # ------ upgrade with dselect
Apt-Cache depends # ------- (package knows how to use dependencies)
Apt-Cache rdepends # ------ (does package know a specific dependency? # Check which packages the package depends on ...)
Sudo apt-Get build-dep # ------ (package installation related compilation environment)
Apt-Get source # ------ (package downloads the package's Source code )
Sudo apt-Get Clean & sudo apt-Get autoclean # -------- clear the downloaded file
Files & only clear outdated packages
Sudo apt-Get check # ------- check for any corrupted Dependencies


Apt-Get install usage
Apt-Get install <package>
Download <package> and all dependent packages, and install or upgrade the packages. 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] <package>
Remove <package> and any other packages dependent on this package. -- purge indicates that this 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 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 the package to the latest available version. old packages will not be installed or removed. if a package has changed its dependency and needs to be installed with a new package, it will not be upgraded, but will be marked as hold. apt-Get update will not upgrade the package marked as "hold" (this is what "hold" means ). see how to manually set the package to hold. I suggest using 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 will be installed and removed to meet the dependency. Therefore, it is dangerous.

Apt-cache search <pattern>
Search for packages and descriptions that meet <pattern> requirements.

Apt-Cache show <package>
Displays the complete description of <package>.

Apt-Cache showpkg <package>
Show <package> many details and relationships with other packages.

Dselect, console-apt, aptitude, and gnome-APT are 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.

-------------------------------------

Ii. Usage of dpkg (Ubuntu Linux package management tool 2)
Dpkg-I <package. Deb>
Install a Debian package file, such as the file you downloaded manually.

Dpkg-C <package. Deb>
List the contents of <package. Deb>.

Dpkg-I <package. Deb>
Extract package information from <package. Deb>.

Dpkg-r <package>
Remove an installed package.

Dpkg-P <package>
Completely clear an installed package. Unlike remove, remove only deletes data and is executable.
File. Purge also deletes all preparation files.

Dpkg-L <package>
List all the files installed in <package>. Check A. Deb file in dpkg-C.
.

Dpkg-S <package>
Show the information of installed packages. Also, see apt-cache to display the package information in the Debian archive
And dpkg-I to display
The package information extracted from the. Deb file.

Dpkg-reconfigure <package>
Re-prepare an installed package, if it uses debconf (debconf for package installation
For a unified configuration interface). You can re-configure debconf itself, if you want to change its front-end
Or the priority of the question. For example, re-prepare debconf and use a dialog front-end for simple operation:

Dpkg-reconfigure -- frontend = dialog debconf
Change back

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

Dpkg -- Get-selections "<package>"
The current status of the <package> (in command line mode)

Wildcard characters are supported, such:
Debian :~ # Dpkg -- Get-selections * wine *




Note:

------------------------------------- Example:
We are using gaim-0.58 + QQ-plugin, in order to prevent Gaim from being upgraded, we can use
The method is as follows:

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 may find that some software status indicators are purge.
For example, amsn has been installed in advance and 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
For more details, see:
Http://linuxsir.com/bbs/showthread....&threadid=22601

Dpkg-S <File>
Find <File> in the package database and tell you which package contains the file.
First Installed Package)

Build Deb packages from source code

Apt-Get source [-B] <package>
Download a source code package and unlock it.
You must write a Deb-Src record in your/etc/APT/sources. list file to complete this operation.
Task.
If you enter a-B parameter and are root, the Deb package is automatically created.

Apt-Get build-dep <package>
Automatically download and install the package required to create the <package> package through the source code.
Only apt 0.5 and later versions support this function.
Currently, Woody and later versions include this function.
If you have an old version of APT, the easiest way to find dependencies is to view the source package
Debian/control file,
Note that the path is relative to the path in the package.

Common usage, combined with APT-Get source-B, example (as root ):

Apt-Get build-dep <package>
Apt-Get source-B <package>

Will download the source code package, establish dependencies, and then try to compile the source code.

Dpkg-source-x <package. DSC>
If you manually download Program The source code package, which contains several classes
Like .orig.tar.gz,. DSC,
And files like .diff.gz,
Then you can use this command to unpack the source code package for the. DSC file.

Dpkg-buildpackage
Create a deb package from the Debian source code tree. It takes effect only in the source tree home directory. Example
For example:

Dpkg-buildpackage-rfakeroot-uc-B

Here '-rfakeroot' specifies the command to use the fakeroot program to mimic the root permission (to implement all
Ownership purpose ),
'-Uc' indicates "Don't cryptographically sign the changelog",'-B 'indicates that only
Binary Package.

Debuild
A Fast packaging script, similar to dpkg-buildpackage, can automatically identify whether to use fakeroot,
Run lintian and GPG

Modify dependency relationship

Dpkg -- configure -- pending
If dpkg fails to exit when apt-Get install upgrade dist-uptradeing,
Use this command to configure unpack packages.
Use apt-Get install, upgrade, or dist-upgrade-F,
Then use apt-Get install, upgrade, or dist-upgrade.

It may be repeated multiple times, which usually solves most of the dependency problems.
(If you are prompted to require a specific package for some reason, you can install or uninstall the package with common sense)

Apt-Get install-F
Apt-Get upgrade-F
Apt-Get dist-upgrade-F
Try to correct the dependency in the above process
Note that <package> is not required for apt-Get install-f.



-------------------------------------
Use apt-CDROM-D/Media/cdrom0 add to load the optical drive,

/Dev/HDC/CDROM iso9660 user, noauto 0 0
Use the editor to modify the disk and restart it.
Then, Apt-CDROM-D/CDROM add
Apt-Get install (the software name you want to install: GCC for example)
Software related to GCC is automatically loaded.
Yesterday, I just tried it. It's amazing.
Note: APT does not recognize the optical drive you manually attached. If the fstab settings are incorrect, APT will not work normally.

Use apt-CDROM-D/Media/cdrom0 add to load the optical drive,
You need to use # mkdir/Media/cdrom0. Otherwise, an error will be prompted: "The file system cannot be read and mounted.
Click/Media/CDROM status-Stat (2 does not have that file or directory )"
-------------------------------------

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.