Linux Package Management:
Api:application Programming Interface
Posix:portable OS
Program Source--preprocessing----compile-to-link
Static compilation:
Shared Compilation:. So
Abi:application Binary Interface
Windows is incompatible with Linux
ELF (executable and Linkable Format)
PE (portable Executable)
Library-level virtualization:
Linux:wine
Windows:cywin
Package Naming:
SOURCE Code: Name-version.tar.gz|bz2|xz
VERSION:major.minor.release
RPM Package Naming method:
name-version-release.arch.rpm
Example: bash-4.2.46-19.el7.x86_64.rpm
VERSION:major.minor.release
Release:release. OS
Common Arch:
x86:i386, i486, i586, i686
x86_64:x64, x86_64, AMD64POWERPC:PPC
Platform Agnostic: Noarch
Package: Sorting and unpacking
Application-version-arch.rpm: Main Package
application-devel-version-arch.rpm Development Sub-package
application-utils-version-arhc.rpm other Sub-packages
application-libs-version-arhc.rpm other Sub-packages
Between packages: there may be dependencies, or even cyclic dependencies
To resolve the dependency package management Tool:
YUM:RPM Package Manager Front-End Tools
Apt-get:deb Package Manager Front End Tool
RPM Front-End management tools on Zypper:suse
Dnf:fedora + RPM Package Manager Front-End management tool
To view the library files that the binaries depend on:
LDD/path/to/binary_file
Manage and view the library files that are loaded natively:
Ldconfig
/sbin/ldconfig-p: displays all available library file names and file path mappings that have been cached by this computer
Configuration files:/etc/ld.so.conf,/etc/ld.so.conf.d/*.conf
Cache Files:/etc/ld.so.cache
Package Manager:
Function: package The compilation of the application of the components of one or several package files, so as to quickly and easily implement package installation, uninstallation, query, upgrade and verify management operations
1. Package file composition (unique for each Package)
The files in the RPM package
RPM metadata, such as name, version, dependency, description, etc.
Scripts to run when installing or uninstalling
2. Database (public)
Package Name and version
Dependent relationships
Function description
File path and checksum information generated after package installation
How to manage Packages:
Using Package manager: rpm
Using the front end tool: yum, DNF
Ways to get Packages:
(1) the system issued by the CD or the official server;
CentOS image:
https://www.centos.org/download/
Http://mirrors.aliyun.com
Http://mirrors.sohu.com
Http://mirrors.163.com
(2) official site of the project
(3) Third party Organizations:
Fedora-epel:
Extra Packages for Enterprise Linux
Rpmforge:rhel recommended, the package is full
Search engine:
http://pkgs.org
Http://rpmfind.net
Http://rpm.pbone.net
https://sourceforge.net/
(4) Make your own
Note: check its legitimacy: source legitimacy, package Integrity
using the RPM command management package on the CentOS system :
installation, uninstallation, upgrade, query, checksum, Database Maintenance
Installation:
RPM {-i|--install} [install-options] package_file ...
-v:verbose
-vv:
-h: Show package Management execution progress with #
Rpm-ivhpackage_file ...
[install-options]
--test: Test installation, But do not actually perform installation; dry run mode
--nodeps: Ignoring dependencies
--replacepkgs| Replacefiles
--nosignature: does not check the legitimacy of the source
--nodigest: Package integrity is not checked
--noscripts: does not execute Package script
%pre: Pre-installation;--nopre
%post: post-installation Script;--nopost
%preun: unloading the Forefoot;--nopreun
%postun: Post-uninstall Script;--nopostun
Upgrade:
RPM {-u|--upgrade} [install-options] package_file ...
RPM {-f|--freshen} [install-options] package_file ...
Upgrade: install an older version of the package, then "upgrade"
If there is no legacy package, the install
Freshen: install an older version of the package, then "upgrade"
If the legacy package does not exist, the upgrade operation is not performed
Rpm-uvhpackage_file ...
Rpm-fvhpackage_file ...
--oldpackage: downgrade
--force: forced escalation
Attention:
(1) do not upgrade the kernel, Linux supports multi-core version coexistence, therefore, the direct installation of the new version of the kernel
(2) if the original package configuration file has been modified after installation, upgrade, the new version of the same profile provided does not directly overwrite the old version of the configuration file, and the new version of the file renamed (filename.rpmnew) retained
RPM Package Query:
RPM {-q|--query} [select-options] [query-options]
[select-options]
-a: All Packages
-f: to see which package installs the specified file for build
-p rpmfile: query operation for the package files that have not been installed;
--whatprovidescapability: query which package is supplied by the specified capability
--whatrequirescapability: queries the specified capability by which package is dependent
Rpm2cpio Package files |cpio–itv Preview in-package files
Rpm2cpio package file |cpio–id "*.conf" release in-package files
[query-options]
--changelog: query RPM package for Changelog
-c: querying the Program's configuration file
-d: querying the Program's documentation
-i:information
-l: view all files generated after the installation of the specified package;
--scripts: script that comes with the package
-r: Query the capability that the specified package depends on;
--provides: lists the capability provided by the specified package;
Query usage:
-qi package, (check inode)-qffile, (check which package the specified file is GENERATED)-QC packages, (check the configuration file)-qlpackage, (check the installation of the program to generate a list)-qdpackage (check the package after the installation of the Document)
-qpipackage_file,-qplpackage_file, ...
-qa
Unloading:
RPM {-e|--erase} [--allmatches] [--nodeps] [--noscripts] [--notriggers] [--test] package_name ...
RPM Common Command Collation:
-a: Query All packages;
-b< Completion Phase >< Kit file >+ or-t < finish phase >< Kit file >+: Set the completion phase of the packaging kit and specify the file name of the kit file;
-c: only configuration profiles are listed, This parameter should be used with "-l" parameter;-d: only text files are listed, This parameter should be used with "-l" parameter;
-e< Kit File > or--erase< kit;: Delete the specified package;
-f< file >+: Query The suite that owns the specified file;
-h Or--hash: the tag is listed when the kit is Installed;-i: displays information about the kit;
-i< Kit File > or--install< kit;: Install the specified kit file;
-l: displays a list of files for the suite;
-p< Kit File >+: Query the specified RPM kit file;
-q: using the inquiry mode, the rpm instruction will ask the user first when any problems are encountered;
-r: Displays the correlation information of the kit;
-s: Display the file status, This parameter should be used with "-l" parameter;
-u< Kit File > or--upgrade< kit;: upgrade the specified package file;
-v: Displays the instruction execution process;
-vv: shows the instruction execution process in detail, which is convenient for troubleshooting.
Package Validation
Validation and completeness of package source legality:
Integrity Verification: SHA256
SOURCE legality verification: RSA
Public Key Cryptography:
Symmetric encryption: encryption, decryption using the same key;
Asymmetric encryption: The key is in pairs
Public Key: Private key, public owner
Secret key: private key, cannot be exposed
To import the required public key:
Rpm-k|checksigrpmfile checking the integrity and signature of packages
Rpm--import /etc/pki/rpm-gpg/rpm-gpg-key-centos-7
CentOS 7 release CD Offers: rpm-gpg-key-centos-7
rpm-qagpg-pubkey*
Database rebuild:
/var/lib/rpm
RPM {--initdb|--rebuilddb}
Initdb: initialization
If the database does not exist beforehand, the new
otherwise, no action is taken
Rebuilddb: Rebuilding the database index directory for an installed header
Yum
Yum:yellowdogupdate Modifier,rpm's Front-End program to address package dependencies, Locate packages between multiple libraries, up2date alternative tools
Yum Repository:yum repo, which stores a wide range of RPM packages and related metadata files for packages (placed in a specific directory Repodata)
File Server:
ftp://
/http
file:///
Yum Client Configuration File:
/etc/yum.conf: providing public configuration for all warehouses
/etc/yum.repos.d/*.repo: provides configuration for the point of the warehouse
Definition of Warehouse Point:
[repositoryid]
Name=some name for this repository
baseurl=url://path/to/repository/
enabled={1|0}
gpgcheck={1|0}
Gpgkey=url
enablegroups={1|0}
failovermethod={roundrobin|priority}
The default is: roundrobin, meaning random selection;
cost= defaults to 1000
Usage of the Yum command:
Yum [options] [command] [package ...]
Yum-config-manager--disable "warehouse name" Disable Warehouse
Yum-config-manager--enable "warehouse name" enabled Warehouse
Show Warehouse List:
Yum Repolist [all|enabled|disabled]
Show Packages:
Yum List
Yum List [all | glob_exp1] [glob_exp2] [...]
Yum List {available|installed|updates} [glob_exp1] [...]
To install the Package:
Yum Install Package1 [package2] [...]
Yum Reinstall Package1 [package2] [...] (reinstall)
Upgrade Package:
Yum Update [package1] [package2] [...]
Yum downgrade Package1 [package2] [...] Downgrade
Check for available upgrades:
Yum Check-update
To uninstall a package:
Yum Remove | Erase Package1 [package2] [...]
To view the package information:
Yum Info [...]
View which package is provided by the specified attribute (which can be a file):
Yum provides | Whatprovidesfeature1 [feature2] [...]
To clean up the local cache:
Yum Clean [packages | metadata | expire-cache | rpmdb| Plugins | all]
Build Cache:
Yum Makecache
Search: Yum Search string1 [string2] [...]
Search for Package name and summary information with the specified keyword
View the capabilities that the specified package depends on:
Yum deplist package1 [package2] [...]
View Yum Transaction history:
Yum History [info|list|packages-list|packages-info|
summary|addon-info|redo|undo|
rollback|new|sync|stats]
Yum history
Yum History Info 6
Yum History undo 6
Log:/var/log/yum.log
To install and upgrade the local package:
Yum Localinstall rpmfile1 [rpmfile2] [...]
(replace with Install)
Yum localupdate rpmfile1 [rpmfile2] [...]
(replace with Update)
Related commands for package group Management:
Yum Groupinstall group1 [group2] [...]
Yum groupupdate group1 [group2] [...]
Yum grouplist [hidden] [groupwildcard] [...]
Yum groupremove group1 [group2] [...]
Yum GroupInfo group1 [...]
Yum command-line options:
--nogpgcheck: Prohibit Gpgcheck
-y: Auto Answer "yes"
-q: Silent mode
--disablerepo=repoidglob: temporarily disables the repo specified here
--enablerepo=repoidglob: temporarily enable the repo specified here
--noplugins: Disable all Plugins
The variables available in the Yum repo configuration file:
$releasever: major version number of the current OS release
$arch: platform, i386,i486,i586,x86_64, etc.
$basearch: Basic platform; i386
$YUM 0-$YUM 9: Custom variables
Instance:
http://server/centos/$releasever/$basearch/
Http://server/centos/7/x86_64
http://server/centos/6/i384
To create a Yum repository:
createrepo[options] <directory>
Package compilation Installation:
Application-version-release.src.rpm--> after installation, use the Rpmbuild command to make the RPM package in binary format before installing
SOURCE code---preprocessing----compile--------
Source Code Organization Format:
Multiple files: between the code in the file, there is likely to be a cross-file dependency
C, c++:make (project manager, configure--
Makefile.in-Makefile)
Java:maven
C Code compilation installation three Steps:
1,./configure:
(1) Pass the parameter through the option, specify enable feature, install path, etc., refer to User's designation and makefile.in file generation makefile when executing
(2) Check the dependent external environment, such as dependent packages
2. Make: Build the application according to the makefile file
3. Make install: copy files to the appropriate path
Development Tools:
Autoconf: Generate Configure Script
Automake: Generate makefile.in
Note: See Install,readme before installing
Source code acquisition of open source Program:
Official self-built site:
apache.org (asf:apache Software Foundation)
mariadb.org
...
Code hosting:
SourceForge.net
Github.com
Code.google.com
C + + compiler: gcc (GNU c complier)
Compile C source Code:
Preparation: provide development tools and development environment
Development Tools: make, gcc, etc.
Development environment: Development library, header file
Glibc: Standard Library
Implementation: providing development components through "package groups"
CentOS 6:
Development Tools
Server Platform Development
CentOS 7:
Development Tools
Development and Creative Workstation
First Step: Configure script
Options: Specify the installation location, specify the enabled features
--help: get the options it supports
Option Categories:
Installation path Settings:
--prefix=/path: Specifies the default installation location, which defaults to/usr/local/
--sysconfdir=/path: Configuration File Installation location
System Types: Cross-compilation Supported
Optional Features: Optional Features
--disable-feature
--enable-feature[=arg]
Optional Packages: Optional package,
--with-package[=arg], Dependent Packages
--without-package, Disabling dependencies
Step two: Make
Step three: Make Install
Post-Installation configuration:
(1) the binary program directory is imported into the PATH environment variable;
Edit file/etc/profile.d/name.sh
Export Path=/path/to/bin: $PATH
(2) Import Library file path
Edit/etc/ld.so.conf.d/name.conf
Add a new library file in the same directory as this file
To have the system regenerate the Cache:
ldconfig[-v]
(3) Import Header File
Implemented in a link-based manner:
Ln-sv
(4) Import Help Manual
edit/etc/man.config|man_db.conf file
Add a Manpath
Bubble sort Exercises:
1, Enter a number of values into the array, using the bubbling algorithm to sort ascending or descending order
#/bin/bash
Declare-a Rand
rand= ([email Protected])
I=$[${#rand [@]}-1]
For n in ' seq 1 $i '
Do
For j in ' seq 1 $i '
Do
[${rand[$j]}-lt ${rand[$[$j-1]}] && c=${rand[$j]} && rand[$j]=${rand[$[$j-1]} && rand[$[$ j-1]]= $c
Done
Done
Echo ${rand[@]}
[[email protected] rpm]#/root/bin/maopao2.sh 2343 64 5 656 756758 56 4 356 261 284 8657 67 45 848
4 5 45 56 64 67 261 284 356 656 848 2343 8657 756758
This article is from the "zebra930" blog, make sure to keep this source http://zebra930.blog.51cto.com/11736340/1841647
Linux Package Management Rpm,yum and compilation installation and bubbling sequencing exercises