APT howto Study Notes

Source: Internet
Author: User

Basic Configuration

1. Basic Format of the/etc/APT/sources. list file:

Deb http://site.http.org/debian distribution Section1 section2 section3
The Deb-Src http://site.http.org/debian distribution Section1 section2 section3

Deb Binary Package Deb-Src original code package
For example:

Deb http://http.us.debian.org/debian stable main contrib non-free
Deb-Src http://non-us.debian.org/debian-non-US stable non-US

Deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
Deb-Src http://http.us.debian.org/debian stable main contrib non-free

APT ignores the rows starting "#".

Note: After modifying/etc/APT/sources. List, update the database list in time.

2. Create a local Apt

# Mkdir/root/Debs
Test the self-collected. Deb package to the/root/Debs directory.
# Dpkg-scanpackages Debs | gzip> Debs/packages.gz
Add the following content to/etc/APT/sources. listdeb:
File:/root Debs/

3. Find the fastest download mirror: netselect, netselect-Apt

Install the netselect package
# Apt-Get install netselect
Test my images
# Netselect security.debian.org ftp.us.debian.org ftp.jp.debian.org non-us.debian.org people.debian.org gluck.debian.org
520 ftp.jp.debian.org
#
I can see that in my image, ftp.jp.debian.org scored 520 at the fastest speed (the lower the score, the better)
Here you can find Debian's image list http://www.debian.org/mirror/mirrors_full
You can also use netselect-apt to download the list.
# Ls sources. List
Ls: Sources. List: file or directory not found
# Netselect-apt stable
(...)
# Ls-l sources. List
Sources. List
#
The premise is that you have installed and run the 'wget' package.

4. Add CD-ROM to your/etc/APT/sources. list file

If you use apt to automatically install software or upgrade the system from the CD-ROM, you can add it to the/etc/APT/sources. list file
# Apt-CDROM add

Note: CD-ROM must be correctly configured in the/etc/fstab file

Ii. Management Package

1. the APT system uses a database list to record which software has been installed in the system, which software has not been installed, and which software can be automatically installed through the apt system. By analyzing this database, Apt-Get determines how to install the software,
Always run # apt-Get update to update this database

2. install the software package
# Apt-Get install packagename
Apt-Get Parameters
-H this help text.
-D download only-do not install or unpack Archives
-F attempt to continue if the integrity check fails
-S no-act. Perform ordering Simulation
-Y Assume yes to all queries and do not prompt
-U show a list of upgraded packages as well

The software package will be downloaded to/var/Cache/APT/archives for later installation.
If a software package is broken, or you just want to reinstall the latest version of the software, you can use the -- reinstall parameter, as shown in figure
# Apt-Get -- reinstall install TPD
When installing the software, you can use apt-Get install package/distribution or apt-Get install package = version to specify the software installation version, as shown in figure
# Apt-Get install Nautilus/unstable

3. Remove the Software Package
Apt-Get remove package
# Apt-Get remove gnome-panel
In this way, gnome-panel and the software package dependent on gnome-panel will be removed. You cannot use the apt system to only remove the software, but the software package that is dependent on it will be retained.
Apt-Get remove package does not remove the configuration files of these software.
# Apt-Get -- purge remove gnome-panel
You can remove the configuration file.

4. Upgrade the Software Package
Apt-Get upgrade

5. upgrade to a new version.
# Apt-get-u dist-Upgrade

6. Remove useless software packages
When installing the software, the software package is first downloaded to the/var/Cache/APT/archives/directory and then installed. In this way, the directory space will become larger and larger. Fortunately, APT provides corresponding management tools.
Apt-Get clean: delete all the packages in the/var/Cache/APT/archives/AND/var/Cache/APT/archives/partial/directories (except locked ).
Apt-Get autoclean only deletes packages that can no longer be downloaded

7.
8. How to maintain a hybrid system
The unstable version of testing is more stable than the stable version. Many people use testing, but some people want to run the latest version of a software, but they do not want to upgrade the system to unstable, to use a hybrid system, you can do this:
Add the following content to/etc/APT/apt. conf:
APT: default-release "testing ";
When you want to install the unstable software, add the-t parameter:
# Apt-get-T unstable install packagename
Note: Do not forget to add the corresponding source to/etc/APT/sources. List.

9. upgrade software from a specific Debian version
# Apt-Get install 'apt-show-versions-u-B | grep unstable'

10. How to Avoid the upgrade of specific software during software upgrade
If the bebian version you are using is later than 2.2, you only need to modify the/etc/APT/preferences file.
The format is very simple:
Package:

Pin:

Priority:

For example, to maintain Gaim version 0.58, you only need to add:
Package: Gaim
Pin: Version 0.58 *
The wildcard * is used to lock all versions starting with 0.58. This means that even if 0.58-1 or similar versions exist, they will not be installed.
Priority (priority) is optional default 989
<0 this software will never be installed
0 ~ 100 the software is not installed and is not a valid version
> 100 the software will be installed. That is, if an updated version is available, the software will be upgraded.
100 ~ 1000 the software will not be downgraded for installation. For example, the Gaim 0.59 I installed will lock the Gaim 0.58 with a priority of 999.
0.58 won't be installed. If you want to downgrade the installation, the priority may be higher than 1000.

Obtain Software Information

1. Search for software names
# Apt-cache search Gaim
Software Information
# Apt-Cache show Gaim
If a new version is installed, it will be displayed.
Get more information
# Apt-Cache showpkg Gaim
Query software Dependencies
# Apt-Cache depends Gaim

2. query the software name with dpkg
Query software names based on a file
# Dpkg-s stdio. h

3. inquired Installation
# Auto-apt Run Command

4. query the object ownership
# Apt-file search filename
It is like dpkg-S, but it can be queried, but it can be found that the software package is not installed.
You can also query the files contained in a package.
# Apt-file list packagename
It will use the database, so it should be updated in time
# Apt-file update

Program Source File

1. Download the program source code
# Apt-Get source packagename
In this way, the three files a .orig.tar.gz, A. DSC and a .diff.gz will be downloaded.
Automatically package after download
# Apt-get-B Source packagename

2. Compile the software
# Apt-Get build-dep GMC
Download the dependencies of the compiled package

 

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.