In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Linux package Management:
API:Application Programming Interface
POSIX:Portable OS
Program source code-- > preprocessing-- > compilation-- > assembly-- > link
Static compilation:
Shared compilation: .so
ABI:Application Binary Interface
Windows is not compatible 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
How the rpm package is named:
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 independent: noarch
Packages: sorting and unpacking
Application-VERSION-ARCH.rpm: main package
Application-devel-VERSION-ARCH.rpm development subpackage
Other subpackages of Application-utils-VERSION-ARHC.rpm
Other subpackages of Application-libs-VERSION-ARHC.rpm
Between packages: there may be dependencies, even circular dependencies
Resolve dependency package management tools:
Front-end tools for yum:rpm package manager
Apt-get:deb package Manager front-end tools
Zypper: rpm front-end management tool on suse
Dnf: Fedora 18 + rpm package Manager front-end management tool
View the library files that the binary depends on:
Ldd/PATH/TO/BINARY_FILE
Manage and view the library files loaded on this machine:
Ldconfig
/ sbin/ldconfig-p: displays all available library file names and file path mapping relationships that have been cached on this machine
Configuration file: / etc/ld.so.conf, / etc/ld.so.conf.d/*.conf
Cache file: / etc/ld.so.cache
Package Manager:
Function: package one or more package files from each component file of the compiled application, so as to easily and quickly realize the management operations such as installation, uninstallation, query, upgrade and verification of the package.
1. Composition of package files (unique to each package)
Files in the RPM package
RPM metadata, such as name, version, dependency, description, etc.
Scripts that run when installing or uninstalling
2. Database (public)
Package name and version
Dependency relationship
Function description
File path and check code information generated after package installation
How to manage packages:
Use the package manager: rpm
Use front-end tools: yum, dnf
The way to get the package:
(1) the CD-ROM of the system version 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
Recommended by Rpmforge:RHEL, the package is very complete
Search engine:
Http://pkgs.org
Http://rpmfind.net
Http://rpm.pbone.net
Https://sourceforge.net/
(4) make it yourself.
Note: check its legitimacy: source legitimacy, package integrity
Use the rpm command to manage the package on a CentOS system:
Installation, uninstallation, upgrade, query, verification, database maintenance
Installation:
Rpm {- I |-- install} [install-options] PACKAGE_FILE...
-v: verbose
-vv:
-h: displays the progress of package management execution in #
Rpm-ivhPACKAGE_FILE...
[install-options]
-- test: test the installation, but do not actually perform the installation; dry run mode
-- nodeps: ignore dependencies
-- replacepkgs | replacefiles
-- nosignature: do not check the validity of the source
-- nodigest: do not check package integrity
-- noscripts: do not execute package scripts
% pre: pre-installation script;-- nopre
% post: post-installation script;-- nopost
% preun: pre-uninstall script;-- nopreun
% postun: script after uninstallation;-- nopostun
Upgrade:
Rpm {- U |-- upgrade} [install-options] PACKAGE_FILE...
Rpm {- F |-- freshen} [install-options] PACKAGE_FILE...
Upgrade: upgrade if an old package is installed
If there is no legacy package, install
Freshen: upgrade if an old package is installed
If there is no legacy package, no upgrade operation is performed
Rpm-UvhPACKAGE_FILE...
Rpm-FvhPACKAGE_FILE...
-- oldpackage: downgrade
-- force: force upgrade
Note:
(1) do not upgrade the kernel; Linux supports the coexistence of multiple kernel versions, so install a new version of the kernel directly
(2) if the configuration file of the original package has been modified after installation, the same configuration file provided by the new version will not directly overwrite the configuration file of the old version, but the new version of the file will be renamed (FILENAME.rpmnew) and retained.
Rpm package query:
Rpm {- Q |-- query} [select-options] [query-options]
[select-options]
-a: all packages
-f: check which package installation generates the specified file
-p rpmfile: query for package files that have not been installed
-- whatprovidesCAPABILITY: query which package provides the specified CAPABILITY
-- whatrequiresCAPABILITY: query which package the specified CAPABILITY is dependent on
Rpm2cpio package files | cpio-itv preview of files in the package
Rpm2cpio package files | cpio-id "* .conf" releases files in the package
[query-options]
-- changelog: query the changelog of the rpm package
-c: the configuration file of the query program
-d: query the documentation of the program
-I: information
-l: view all files generated after the specified package is installed
-- scripts: the script that comes with the package
-R: query the CAPABILITY on which the specified package depends
-- provides: lists the CAPABILITY provided by the specified package
Query usage:
-qi PACKAGE, (check inode)-qfFILE, (find out which package the specified file is generated by)-qc PACKAGE, (check configuration file)-qlPACKAGE, (check the list of packages installed)-qdPACKAGE (check the documentation generated after package installation)
-qpiPACKAGE_FILE.-qplPACKAGE_FILE.
-qa
Uninstall:
Rpm {- e |-- erase} [--allmatches] [--nodeps] [--noscripts] [--notriggers] [--test] PACKAGE_NAME...
Rpm common command collation:
-a: query all suites
-b + or-t +: sets the completion phase of the wrapper package and specifies the file name of the package file
-c: only the configuration file is listed. This parameter should be used with the "- l" parameter.-d: only text files are listed. This parameter should be used with the "- l" parameter.
-e or-- erase: deletes the specified suite
-fallow: query the suite that owns the specified file
-h or-- hash: the tag is listed when the package is installed;-I: displays information about the suite
-I or-- install: installs the specified package file
-l: displays a list of files for the suite
-packs: query the specified RPM package file
-Q: use the query mode. When you encounter any questions, the rpm instruction will ask the user first.
-R: displays the relevance information of the suite
-s: displays the file status. This parameter should be used with the "- l" parameter.
-U or-- upgrade: upgrade the specified package file
-v: displays the instruction execution process
-vv: displays the execution process of the instruction in detail to facilitate troubleshooting.
Packet verification
Validity and integrity verification of package sources:
Integrity verification: SHA256
Verification of Source legitimacy: RSA
Public key encryption:
Symmetric encryption: encrypt and decrypt using the same key
Asymmetric encryption: keys are paired
Public key: public key, public owner
Secret key: private key, cannot be made public
Import the required public key:
Rpm-K | checksigrpmfile checks the integrity and signature of the packet
Rpm--import / etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Available on the CentOS 7 distribution CD: RPM-GPG-KEY-CentOS-7
Rpm-qagpg-pubkey*
Database Reconstruction:
/ var/lib/rpm
Rpm {--initdb |-- rebuilddb}
Initdb: initialization
If the database does not exist in advance, create a new database
Otherwise, no action is performed
Rebuilddb: rebuild the database index directory of the installed package header
Yum
YUM: a front-end program for YellowdogUpdate Modifier,rpm to resolve package-related dependencies and to locate software packages among multiple libraries as an alternative to up2date
Yum repository: yum repo, which stores a large number of rpm packages and related metadata files (placed in a specific directory repodata)
File server:
Ftp://
Http://
File:///
Yum client profile:
/ etc/yum.conf: provide common configuration for all warehouses
/ etc/yum.repos.d/*.repo: provides configuration for pointing to the warehouse
The definition of the 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, which means random selection
Cost= defaults to 1000
Usage of the yum command:
Yum [options] [command] [package...]
Yum-config-manager-disable "warehouse name" disables the warehouse
Yum-config-manager-enable "warehouse name" enables the warehouse
Display a list of warehouses:
Yum repolist [all | enabled | disabled]
Display the package:
Yum list
Yum list [all | glob_exp1] [glob_exp2] [...]
Yum list {available | installed | updates} [glob_exp1] [...]
Install the package:
Yum install package1 [package2] [...]
Yum reinstall package1 [package2] [...] (reinstall)
Upgrade package:
Yum update [package1] [package2] [...]
Yum downgrade package1 [package2] [...] (demoted)
Check for available upgrades:
Yum check-update
Uninstall the package:
Yum remove | erase package1 [package2] [...]
View the package information:
Yum info [...]
To see which package the specified feature (which can be a file) is provided:
Yum provides | whatprovidesfeature1 [feature2] [...]
Clean up the local cache:
Yum clean [packages | metadata | expire-cache | rpmdb | plugins | all]
Build the cache:
Yum makecache
Search: yum search string1 [string2] [...]
Search for package name and summary information with specified keywords
View the capabilities on which the specified package depends:
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
Install and upgrade local packages:
Yum localinstall rpmfile1 [rpmfile2] [...]
(replace with install)
Yum localupdate rpmfile1 [rpmfile2] [...]
(replace with update)
Commands related to package group management:
Yum groupinstall group1 [group2] [...]
Yum groupupdate group1 [group2] [...]
Yum grouplist [hidden] [groupwildcard] [...]
Yum groupremove group1 [group2] [...]
Yum groupinfo group1 [...]
Command line options for yum:
-- nogpgcheck: gpgcheck is prohibited
-y: automatic answer is "yes"
-Q: silent mode
-- disablerepo=repoidglob: temporarily disable the repo specified here
-- enablerepo=repoidglob: temporarily enable the repo specified here
-- noplugins: disable all plug-ins
The variables available in the repo configuration file of yum:
$releasever: the major version number of the current OS release
$arch: platform, i386, 486, i486, 586, x86, 64, etc.
$basearch: basic platform; i386
$YUM0-$YUM9: custom variable
Example:
Http://server/centos/$releasever/$basearch/
Http://server/centos/7/x86_64
Http://server/centos/6/i384
Create a yum repository:
Createrepo [options]
Package compilation and installation:
After Application-VERSION-release.src.rpm-- > installation, use the rpmbuild command to make the rpm package in binary format, and then install it
Source code-- > preprocessing-- > compile-- > assemble-- > link-- > execute
Source code organization format:
Multiple files: there are likely to be cross-file dependencies between the code in the file
C, C++:make (Project Manager, configure-- >
Makefile.in-- > makefile)
Java: maven
C code compilation and installation three steps:
1 、. / configure:
(1) pass parameters through options to specify the enabled feature, installation path, etc. During execution, you will refer to the user's assignment and makefile.in file to generate makefile.
(2) check the dependent external environment, such as dependent software packages
2. Make: build the application according to the makefile file
3. Make install: copy the file to the appropriate path
Development tools:
Autoconf: generate configure script
Automake: generate Makefile.in
Note: check INSTALL,README before installation
Access to source code of open source programs:
Official self-built site:
Apache.org (ASF:Apache Software Foundation)
Mariadb.org
...
Code hosting:
SourceForge.net
Github.com
Code.google.com
C _ blank + compiler: gcc (GNU C Complier)
Compile the C source code:
Preparation: provide development tools and development environment
Development tools: make, gcc, etc.
Development environment: development libraries, header files
Glibc: standard library
Implementation: provide development components through "package groups"
CentOS 6:
Development Tools
Server Platform Development
CentOS 7:
Development Tools
Development and Creative Workstation
Step 1: configure script
Options: specify installation location, specify enabled features
-- help: get the options it supports
Option classification:
Installation path setting:
-- prefix=/PATH: specify the default installation location. Default is / usr/local/.
-- sysconfdir=/PATH: configuration file installation location
System types: support for cross-compilation
Optional Features: optional featur
-- disable-FEATURE
-- enable-FEATURE [= ARG]
Optional Packages: optional package
-- with-PACKAGE [= ARG], dependent package
-- without-PACKAGE, disable dependencies
Step 2: make
Step 3: make install
Configuration after installation:
(1) Import the binary program directory 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 the directory where the new library file is located to this file
Have the system regenerate the cache:
Ldconfig [- v]
(3) Import header file
A link-based approach to:
Ln-sv
(4) Import help manual
Edit / etc/man.config | man_db.conf file
Add a MANPATH
Bubble sorting exercises:
1. Enter several values into the array and sort them in ascending or descending order by bubbling algorithm.
# / bin/bash
Declare-a rand
Rand= ($@)
ITunes $[${# rand [@]}-1]
For n in `seq 1$ i`
Do
For j in `seq 1$ i`
Do
[${rand [$j]}-lt ${rand [$[$jmur1]]}] & & rand ${rand [$j]} & & rand [$j] = ${rand [$[$jmur1]]} & & rand [$[$Jmur1]] = $c
Done
Done
Echo ${rand [@]}
[root@localhost rpm] # / root/bin/maopao2.sh 2343 64 5 656 756758 56 4 356 261 284 8657 67 45 848
45 45 56 64 67 261 284 356 656 848 2343 8657 756758
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 247
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.