軟件包管理

軟件運行環境

ABI(應用程序的二進制接口):Application Binary Interface

Windows Linux 不兼容

ELF(Executable and Linkable Format)           —>Linux

可執行可連接的格式

PE Portable Executable) )               —>Windows

可移植的可執行格式

庫級別的虛擬化:

Linux: WINE

Windows: Cywin

API(應用程序的開發接口):Application Programming Interface

POSIX Portable OS

程序源代碼 –>預處理 –>編譯 –>匯編 –>鏈接

靜態編譯:.a

動態編譯:.so

靜態和動態鏈接

鏈接主要作用是把各個模塊之間相互引用的部分處理好,使得各個模塊之間能夠正確地銜接,分為靜態鏈接和動態鏈接

靜態鏈接

     把程序對應的依賴庫復制一份到包

     libxxx.a

     嵌入程序包

     升級難,需重新編譯

     占用較多空間,遷移容易

動態鏈接

     只把依賴加做一個動態鏈接

     libxxx.so

     “連接指向”

     占用較少空間升級方便

開發語言:

系統級開發

C,C++

應用級開發

Java,Delphi,Python,Go,Php,Perl,Ruby

 

軟件包基礎

包管理器

二進制應用程序的組成部分:

二進制文件、庫文件、配置文件、幫助文件

程序包管理器:

debian deb 文件, dpkg 包管理器

redhat: rpm 文件, rpm 包管理器

rpm: Redhat Package Manager(軟件包管理器)

RPM Package Manager

 

包命名

源代碼:name-VERSION.tar.gz|bz2|xz

VERSION(版本): major.minor.release

rpm 包命名方式:

name-VERSION-release.arch.rpm

例: bash-4.2.46-19.el7.x86_64.rpm

VERSION: major.minor.release

Release release.OS

常見的arch

x86: i386, i486, i586, i686

x86_64: x64, x86_64, amd64

powerpc: ppc

跟平臺無關:noarch

包命名和工具

包:分類 拆包

Application-VERSION-ARCH.rpm:  主包

應用程序庫版本

Application-devel-VERSION-ARCH.rpm  開發子包

Application-utils-VERSION-ARHC.rpm  其它子包

Application-libs-VERSION-ARHC.rpm  其它 子包

包之間:可能存在依賴關系,甚至循環依賴

(安裝A包時,A包依賴于B包,B包依賴于C包,C包依賴于A包)

解決依賴包管理工具:

Yum rpm 包管理器的前端工具

apt-get deb 包管理器前端工具

zypper: suse 上的rpm 前端管理工具

dnf: Fedora 18+ rpm 包管理器前端管理工具

庫文件

查看二進制程序所依賴的庫文件

ldd /PATH/TO/BINARY_FILE

管理及查看本機裝載的庫文件

ldconfig

/sbin/ldconfig -p:  顯示本機已經緩存的所有可用庫文件

名及文件路徑映射關系

配置文件:/etc/ld.so.conf, /etc/ld.so.conf.d/*.conf

緩存文件:/etc/ld.so.cache

 

程序包管理器:

功能:將編譯好的應用程序的各組成文件打包一個或幾個程序包文件,從而方便快捷地實現程序包的安裝、卸載、查詢、升級和校驗等管理操作

1、包文件組成 ( 每個包獨有)

RPM 包內的文件

RPM 的元數據,如名稱,版本,依賴性,描述等

安裝或卸載時運行的腳本

2、數據庫( 公共) /var/lib/rpm

程序包名稱及版本

依賴關系

功能說明

包安裝后生成的各文件路徑及校驗碼信息

[root@station29 ~]# cd /var/lib/rpm
[root@station29 rpm]# ll
-rw-r--r--. 1 root root 5136384 Mar 24 05:55 Basenames
total 63060
-rw-r--r--. 1 root root 12288 Mar 24 05:53 Conflictname
-rw-r--r--. 1 root root 73728 Apr 17 19:46 __db.001
-rw-r--r--. 1 root root 1318912 Apr 17 19:46 __db.003
-rw-r--r--. 1 root root 237568 Apr 17 19:46 __db.002 -rw-r--r--. 1 root root 753664 Apr 17 19:46 __db.004
-rw-r--r--. 1 root root 5251072 Mar 24 05:55 Filedigests
-rw-r--r--. 1 root root 1064960 Mar 24 05:55 Dirnames -rw-r--r--. 1 root root 20480 Mar 24 05:55 Group -rw-r--r--. 1 root root 20480 Mar 24 05:55 Installtid
-rw-r--r--. 1 root root 24576 Mar 24 05:55 Obsoletename
-rw-r--r--. 1 root root 49152 Mar 24 05:55 Name

                                                                                    程序包的來源

管理程序包的方式:

使用包管理器:rpm

使用前端工具:yum, dnf

獲取程序包的途徑:

(1)系統發版的光盤或官方的服務器;

CentOS 鏡像:

https://www.centos.org/download/

http://mirrors.aliyun.com

http://mirrors.sohu.com

http://mirrors.163.com

(2)項目官方站點

       (3)第三方組織:

Fedora-EPEL

Extra Packages for Enterprise Linux

Rpmforge:RHEL 推薦,包很全

搜索引擎

http://pkgs.org

http://rpmfind.net

http://rpm.pbone.net

https://sourceforge.net/

     (4)自己制作

FPM 制作安裝包

注意:第三方包建議要檢查其合法性

  來源合法性, 程序包的完整性

 

rpm 包管理

CentOS 系統上使用rpm 命令管理程序包:

安裝、卸載、升級、查詢、校驗、數據庫維護

安裝:

rpm {-i|–install} [install-options] PACKAGE_FILE

-v: verbose 顯示安裝過程中的詳細信息

-vv: 顯示安裝過程中更詳細的信息

-h: # 顯示程序包管理執行進度

rpm -ivh PACKAGE_FILE …

[root@localhost/]#rpm -ivh /run/media/root/CentOS\ 7\ x86_64/Packages/tree-1.6.0-10.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
    package tree-1.6.0-10.el7.x86_64 is already installed   (已經安裝完成)
[root@localhost /]# rpm -q tree
tree-1.6.0-10.el7.x86_64
[root@localhost /]# tree /dev/
/dev/
├── agpgart
├── autofs
├── block
│   ├── 11:0 -> ../sr0
│   ├── 253:0 -> ../dm-0
│   ├── 253:1 -> ../dm-1
│   ├── 253:2 -> ../dm-2
│   ├── 8:0 -> ../sda
│   ├── 8:1 -> ../sda1
│   ├── 8:16 -> ../sdb
│   └── 8:2 -> ../sda2
├── bsg
│   ├── 1:0:0:0
│   ├── 2:0:0:0
│   └── 2:0:1:0

rpm 包安裝

 [install-options]

–test:  測試安裝,但不真正 執行安裝,即dry run 模式

[root@localhost~]#rpm -ivh /run/media/root/CentOS\ 7\ x86_64/Packages/tree-1.6.0-10.el7.x86_64.rpm --test 
Preparing...                          ################################# [100%]
    package tree-1.6.0-10.el7.x86_64 is already installed

–nodeps :忽略依賴關系

–replacepkgs | replacefiles  

       (replacepkgs 覆蓋安裝   包損壞時可用)

(replacefiles  覆蓋沖突文件)

[root@localhost ~]# rm /usr/bin/tree
rm: remove regular file ‘/usr/bin/tree’? Y
[root@localhost~]#rpm -ivh /run/media/root/CentOS\ 7\ x86_64/Packages/tree-1.6.0-10.el7.x86_64.rpm --replacepkgs 
Preparing...                      ################################# [100%]
Updating / installing...
1:tree-1.6.0-10.el7                ################################# [100%]

–nosignature:  不檢查來源合法性

–nodigest :不檢查包完整性

–noscripts :不執行 程序包腳本

%pre: ; 安裝前腳本; –nopre

%post: ; 安裝后腳本; –nopost

%preun: ; 卸載前腳本; –nopreun

%postun:  卸載后腳本; –nopostun

[root@localhost~]#rpm -qp --noscripts /run/media/root/CentOS\ 7\ x86_64/Packages/bash-4.2.46-20.el7_2.x86_64.rpm
rpm: script disabling options may only be specified during package installation and erasure
腳本禁用選項只能在包安裝和刪除過程中指定

rpm 包升級

升級:

    rpm {-U|–upgrade} [install-options]  PACKAGE_FILE …

    rpm {-F|–freshen} [install-options]  PACKAGE_FILE …

upgrade :安裝有舊版程序包,則“升級”

如果不存在舊版程序包,則“安裝”

freshen :安裝有舊版程序包,則“升級”

如果不存在舊版程序包,則不執行升級操作

rpm -Uvh PACKAGE_FILE …

rpm -Fvh PACKAGE_FILE …

–oldpackage:降級

–force:強制安裝

注意:

(1)  不要對內核做升級操作;Linux 支持多內核版本并存,因此,直接安裝新版本內核

(2)  如果原程序包的配置文件安裝后曾被修改,升級時,新版本的提供的同一個配置文件并不會直接覆蓋老版本的配置文件,而把新版本的文件重命名(FILENAME.rpmnew) 后保留

例:將CentOS6.8升級為CentOS9
1.將光盤掛載改為新下好的CentOS9 ios 
2.df查詢
[root@station29 Packages]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda6      173059896 3639456 160622796   3% /
tmpfs            1019184      80   1019104   1% /dev/shm
/dev/sda1         194241   39027    144974  22% /boot
/dev/sda2       20511356   45032  19417748   1% /data
/dev/sda3       10190136   40504   9625344   1% /home
/dev/sr0         3878870 3878870         0 100% /media/CentOS_6.9_Final

[root@station29 Packages]# rpm -q kernel
kernel-2.6.32-642.el6.x86_64            (當前版本內核)

[root@station29 Packages]# ls kernel*
kernel-2.6.32-696.el6.x86_64.rpm (最新版本內核)   kernel-doc-2.6.32-696.el6.noarch.rpm
kernel-abi-whitelists-2.6.32-696.el6.noarch.rpm  kernel-firmware-2.6.32-696.el6.noarch.rpm
kernel-devel-2.6.32-696.el6.x86_64.rpm           kernel-headers-2.6.32-696.el6.x86_64.rpm

[root@station29 Packages]# rpm -ivh kernel-2.6.32-696.el6.x86_64.rpm 
error: Failed dependencies:
    kernel-firmware >= 2.6.32-696.el6 is needed by kernel-2.6.32-696.el6.x86_64
(內核固件> = 2.6.32-696.el6需要kernel-2.6.32-696.el6.x86_64)

[root@station29 Packages]# rpm -ivh kernel-2.6.32-696.el6.x86_64.rpm kernel-firmware-2.6.32-696.el6.noarch.rpm 
Preparing...                ########################################### [100%]
   1:kernel-firmware        ########################################### [ 50%]
   2:kernel                ########################################### [100%]

[root@station29 Packages]# rpm -q kernel
kernel-2.6.32-642.el6.x86_64
kernel-2.6.32-696.el6.x86_64
[root@station29 Packages]# reboot        (重新啟動)
Broadcast message from zhouao@station29.magelinux.com
    (/dev/pts/1) at 11:10 ...
The system is going down for reboot NOW!
選擇CentOS6.9
[root@station29 ~]# rpm -q kernel
kernel-2.6.32-642.el6.x86_64
kernel-2.6.32-696.el6.x86_64
[root@station29 ~]# uname -r
2.6.32-696.el6.x86_64
升級成功

包查詢

rpm {-q|–query} [select-options] [query-options]

[select-options]

-a:  所有包

[root@station29 ~]# rpm -qa | grep bas
ncurses-base-5.7-4.20090207.el6.x86_64
gstreamer-plugins-base-0.10.29-2.el6.x86_64
khmeros-base-fonts-5.0-9.el6.noarch
libasyncns-0.8-1.1.el6.x86_64
system-config-keyboard-base-1.3.1-6.el6.x86_64
basesystem-10.0-4.el6.noarch
libbasicobjects-0.1.1-11.el6.x86_64
system-config-firewall-base-1.2.27-7.2.el6_6.noarch
bash-4.1.2-40.el6.x86_64

-f:  查看指定的文件由哪個程序包安裝生成

[root@station29 ~]# rpm -qf /lib64/
filesystem-2.4.30-3.el6.x86_64

-p rpmfile :針對尚未安裝的程序包文件做查詢操作(-p后面跟完整路徑

–whatprovides CAPABILITY :查詢指定的 CAPABILITY由哪個包所提供

[root@station29 ~]# rpm -q --whatprovides bash
bash-4.1.2-40.el6.x86_64

--whatrequires CAPABILITY :查詢指定的 CAPABILITY 被哪個包所依賴
[root@station29 ~]# rpm -q --whatrequires bash
initscripts-9.03.53-1.el6.centos.x86_64
dracut-004-409.el6.noarch
rsyslog-5.8.10-10.el6_6.x86_64
cronie-1.4.4-15.el6_7.1.x86_64
autofs-5.0.5-122.el6.x86_64
lvm2-2.02.143-7.el6.x86_64

rpm2cpio  包文件|cpio itv 預覽包內文件

rpm2cpio  包文件|cpio id *.conf” ”  釋放包內文件

[query-options]

–changelog :查詢rpm 包的changelog

[root@station29 ~]# rpm -q --changelog bash | head -10
* Tue Dec 22 2015 Ondrej Oprala <ooprala@redhat.com> - 4.1.2-40
- Bash shouldn't ignore bash --debugger without a dbger installed
  Related: #1260568

* Wed Nov 25 2015 Ondrej Oprala <ooprala@redhat.com> - 4.1.2-39
- Wrong parsing inside for loop and brackets
  Resolves: #1207803

* Wed Nov 25 2015 Ondrej Oprala <ooprala@redhat.com> - 4.1.2-38
- IFS incorrectly splitting herestrings

-c:  查詢程序的配置文件

[root@station29 ~]# rpm -qc bash
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc

-d:  查詢程序的文檔

[root@station29 ~]# rpm -qd bash
/usr/share/doc/bash-4.1.2/COPYING
/usr/share/info/bash.info.gz
/usr/share/man/man1/..1.gz
/usr/share/man/man1/:.1.gz
/usr/share/man/man1/[.1.gz
/usr/share/man/man1/alias.1.gz
/usr/share/man/man1/bash.1.gz

-i: information(查看信息)

-l:  查看指定的程序包安裝后生成的所有文件

[root@station29 ~]# rpm -ql bash
/bin/bash
/bin/sh
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc
/usr/bin/bashbug-64
/usr/share/doc/bash-4.1.2/COPYING
/usr/share/info/bash.info.gz
/usr/share/locale/af/LC_MESSAGES/bash.mo
/usr/share/locale/bg/LC_MESSAGES/bash.mo
/usr/share/locale/ca/LC_MESSAGES/bash.mo

–scripts :程序包自帶的腳本

[root@station29 ~]# rpm -q bash --scripts
postinstall scriptlet (using <lua>):
bashfound = false;
shfound = false;
 
f = io.open("/etc/shells", "r");
if f == nil
then
  f = io.open("/etc/shells", "w");
else
  repeat
    t = f:read();
    if t == "/bin/bash"
    then
      bashfound = true;
    end
    if t == "/bin/sh"
    then
      shfound = true;
    end
  until t == nil;
end

–provides:  列出指定程序包所提供的CAPABILITY(能力)

[root@station29 ~]# rpm -q --provides bash
config(bash) = 4.1.2-40.el6
bash = 4.1.2-40.el6
bash(x86-64) = 4.1.2-40.el6

常用查詢用法:

-qi PACKAGE, -qf FILE, -qc PACKAGE, -ql PACKAGE, -qd PACKAGE

[root@station29 ~]# rpm -qi tree
Name        : tree                         Relocations: (not relocatable)
Version     : 1.5.3                             Vendor: CentOS
Release     : 3.el6                         Build Date: Wed 14 Jan 2015 08:21:02    PM CST
Install Date: Tue 18 Apr 2017 03:38:46 PM CST      Build Host: c6b9.bsys.dev.centos.org
Group       : Applications/File             Source RPM: tree-1.5.3-3.el6.src.rpm
Size        : 66687                            License: GPLv2+
Signature   : RSA/SHA1, Wed 14 Jan 2015 10:12:21 PM CST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://mama.indstate.edu/users/ice/tree/
Summary     : File system tree viewer
Description :
The tree utility recursively displays the contents of directories in a
tree-like format.  Tree is basically a UNIX port of the DOS tree
utility.

-qpi PACKAGE_FILE, -qpl PACKAGE_FILE, …

[root@station29~]#rpm -qpl /media/CentOS_6.9_Final/Packages/tree-1.5.3-3.el6.x86_64.rpm 
/usr/bin/tree
/usr/share/doc/tree-1.5.3
/usr/share/doc/tree-1.5.3/LICENSE
/usr/share/doc/tree-1.5.3/README
/usr/share/man/man1/tree.1.gz

包卸載:

rpm {-e|–erase} [–allmatches] [–nodeps] [–noscripts] [–notriggers] [–test] PACKAGE_NAME …

包校驗

rpm {-V|–verify} [select-options] [verify-options]

S file Size differs (文件大小改變)

M Mode differs (includes permissions and file type) (模式,權限,文件類型改變)

5 digest (formerly MD5 sum) differs (hash值改變,文件內容變化,hash值隨之變化)

D Device major/minor number mismatch (設備主要號碼和次要號碼)

[root@localhost ~]# ll /dev/sda

brw-rw—-. 1 root disk 8, 0 Apr 20 16:44 /dev/sda

L readLink(2) path mismatch (連接)

U User ownership differs (不同的用戶權限)

G Group ownership differs (不同的組權限)

T mTime differs (時間改變)

P capabilities differ (能力不同)

包來源合法性驗正及完整性驗正

完整性驗正:SHA256

來源合法性驗正:RSA

公鑰加密

對稱加密:加密、解密使用同一密鑰

非對稱加密:密鑰是成對兒的

public key:  公鑰,公開所有人

secret key:  私鑰,  不能公開

導入所需要公鑰

rpm -K|checksig rpmfile 檢查包的完整性和簽名

rpm –import / etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

CentOS 7 發行版光盤提供: RPM-GPG-KEY-CentOS-7

rpm -qa gpg-pubkey*

rpm 數據庫

數據庫重建:

/var/lib/rpm

rpm {–initdb|–rebuilddb}

initdb:  初始化

如果 事先不存在數據庫,則新建之;否則 ,不執行任何操作

rebuilddb :重建已 安裝的包頭的數據庫索引目錄

 

yum 管理

yum

CentOS: yum, dnf

yum: Yellowdog Update Modifier rpm 的前端程序,可解決軟件包相關依賴性,可在多個庫之間定位軟件包,up2date的替代工具

yum repository: yum repo ,存儲了眾多rpm 包,以及包的相關的元數據文件(放置于特定目錄repodata 下)

文件服務器:

ftp://

http://

file://

 

yum 配置文件

yum 客戶端配置文件:

/etc/yum.conf :為所有倉庫提供公共配置

/etc/yum.repos.d/*.repo :為倉庫的指向提供配置

[root@station29 ~]# cd /etc/yum.repos.d/
[root@station29 yum.repos.d]# ls
CentOS-Base.repo       CentOS-fasttrack.repo  CentOS-Vault.repo
CentOS-Debuginfo.repo  CentOS-Media.repo

 

倉庫指向的定義:

[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}

roundrobin: : 意為隨機挑選,默認值

priority: 按順序訪問

cost= 默認為1000

cd /etc/yum.repos.d/
mkdir bak
mv *.repo bak
 vim base.repo
[CentOs6.8]
name=CentOs6.8
baseurl=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
        file:///media/cdrom
http://mirrors.aliyun.com/centos/$releasever/os/$basearch
[epel]
name=CentOs6.8
baseurl=http://172.18.0.1/fedora-epel/6/x86_64/
gpgcheck=0
[base]
baseurl=file:///misc/cd
gpgcheck=0
     
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6        (導入鑰匙)

[centos71]
name=centos71
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pik/rpm-gpg/RPM-GPG-KEY-Centos-7
[epel]
baseurl=http://172.18.0.1/fedora-epel/7/x86_64
gpgcheck=0

yum 倉庫

yum repo 配置文件中可用的變量:

$releasever:  當前OS 的發行版的主版本號

$arch:  平臺,i386,i486,i586,x86_64

$basearch :基礎平臺;i386, x86_64

$YUM0-$YUM9: 自定義變量

實例:

http://server/centos/$releasever/$basearch/

http://server/centos/7/x86_64

http://server/centos/6/i384

 

yum

阿里云repo 文件:

http://mirrors.aliyun.com/repo/

CentOS 系統yum

阿里云:

https://mirrors.aliyun.com/centos/$releasever/os/x86_64/

Epel yum :

阿里云:

https://mirrors.aliyun.com/epel/$releasever/x86_64

yum 命令

yum 命令的用法:

yum [options] [command] [package …]

顯示倉庫列表:

yum repolist [all|enabled|disabled]enabled列出啟用的     disabled列出禁用的)

[root@localhost ~]# yum repolist all
repo id                        repo name                              status
centos7                       centos7                           enabled: 9,363
centos71/7                    centos71                          enabled: 9,363
epel                          epel                                   disabled
repolist: 18,726

顯示程序包:

yum list

yum list [all | glob_exp1] [glob_exp2] […]

列出所有的包,可用正則表達式

yum list {available|installed|updates} [glob_exp1][…]

available列出可用的包;installed列出已經裝好的包;updates列出可更新的包

安裝程序包:

yum install package1 [package2] […]

[root@localhost ~]# yum install createrepo
Loaded plugins: fastestmirror, langpacks
Repository 'epel' is missing name in configuration, using id
Repository 'epel' is missing name in configuration, using id
Repository epel is listed more than once in the configuration
centos7                                             | 3.6 kB  00:00:00     
centos71                                            | 3.6 kB  00:00:00     
(1/4): centos7/group_gz                                | 155 kB  00:00:00     
(2/4): centos7/primary_db                              | 5.6 MB  00:00:00     
(3/4): centos71/7/primary_db                           | 5.6 MB  00:00:07 
yum reinstall package1 [package2] [...] ( 重新安裝)

升級程序包:

yum update [package1] [package2] […]

yum downgrade package1 [package2] […] ( 降級)

檢查可用升級:

yum check-update

卸載程序包:

yum remove | erase package1 [package2] […]

查看程序包information: :

yum info […]

[root@localhost ~]# yum info vsftpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Installed Packages
Name        : vsftpd
Arch        : x86_64
Version     : 3.0.2
Release     : 21.el7
Size        : 348 k
Repo        : installed
From repo   : centos71
Summary     : Very Secure Ftp Daemon
URL         : https://security.appspot.com/vsftpd.html
License     : GPLv2 with exceptions
Description : vsftpd is a Very Secure FTP daemon. It was written completely from
            : scratch.

查看指定的特性( 可以是某文件) 是由哪個程序包所提供:

yum provides | whatprovides feature1 [feature2][…]

[root@localhost ~]# yum provides vsftpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
vsftpd-3.0.2-21.el7.x86_64 : Very Secure Ftp Daemon
Repo        : centos71


vsftpd-3.0.2-21.el7.x86_64 : Very Secure Ftp Daemon
Repo        : @centos71

清理本地緩存:

清除/var/cache/yum/$basearch/$releasever 緩存

yum clean [ packages | metadata | expire-cache | rpmdb | plugins | all ]

[root@localhost ~]# yum clean all 
Loaded plugins: fastestmirror, langpacks
Repository 'epel' is missing name in configuration, using id
Repository 'epel' is missing name in configuration, using id
Repository epel is listed more than once in the configuration
Cleaning repos: centos7 centos71
Cleaning up everything
Cleaning up list of fastest mirrors

構建緩存:

yum makecache

搜索:yum search string1 [string2] […]

以指定的關鍵字搜索程序包名及summary 信息

查看指定包所依賴的capabilities: :

yum deplist package1 [package2] […]

查看yum 事務歷史:

yum history [info|list|packages-list|packages-info|

summary|addon-info|redo|undo|

rollback|new|sync|stats]

yum history(查看yum安裝的歷史列表

實例:
[root@localhost yum.repos.d]# yum history
Loaded plugins: fastestmirror, langpacks
Repository 'epel' is missing name in configuration, using id
Repository 'epel' is missing name in configuration, using id
Repository epel is listed more than once in the configuration
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    10 | root <root>              | 2017-04-21 06:13 | Install        |    1   
     9 | root <root>              | 2017-04-21 06:12 | Install        |    4   
     8 | root <root>              | 2017-04-21 06:10 | Install        |    1   
     7 | putong <putong>          | 2017-04-20 23:42 | Erase          |    4   
     6 | putong <putong>          | 2017-04-20 22:46 | Install        |    1   
     5 | putong <putong>          | 2017-04-20 20:57 | Install        |    1   
     4 | putong <putong>          | 2017-04-20 17:58 | Install        |    1   
     3 | putong <putong>          | 2017-04-20 07:55 | Install        |    1   
     2 | putong <putong>          | 2017-04-20 06:57 | Install        |    1   
     1 | System <unset>           | 2017-03-21 04:20 | Install        | 1587   
history list

yum history info 6(查看編號為9的詳細操作

實例:
[root@localhost yum.repos.d]# yum history info 9
Loaded plugins: fastestmirror, langpacks
Repository 'epel' is missing name in configuration, using id
Repository 'epel' is missing name in configuration, using id
Repository epel is listed more than once in the configuration
Transaction ID : 9
Begin time     : Fri Apr 21 06:12:21 2017
Begin rpmdb    : 1589:b4e72653f9467b7dd4fe8526994f44c67ecabd4e
End time       :            06:12:25 2017 (4 seconds)
End rpmdb      : 1593:2fa17e04d1ea55397e1f0c484335d73b9cd8fc18
User           : root <root>
Return-Code    : Success
Command Line   : install -y apr-util-devel
Transaction performed with:
    Installed     rpm-4.11.3-21.el7.x86_64                      @anaconda
    Installed     yum-3.4.3-150.el7.centos.noarch               @anaconda
    Installed     yum-plugin-fastestmirror-1.1.31-40.el7.noarch @anaconda
Packages Altered:
    Install     apr-util-devel-1.5.2-6.el7.x86_64       @centos7
    Dep-Install cyrus-sasl-devel-2.1.26-20.el7_2.x86_64 @centos7
    Dep-Install expat-devel-2.1.0-8.el7.x86_64          @centos7
    Dep-Install openldap-devel-2.4.40-13.el7.x86_64     @centos7
history info

yum history undo 6(取消/重新進行編號為9yum操作

實例:
[root@localhost yum.repos.d]# yum history undo 9
Loaded plugins: fastestmirror, langpacks
Repository 'epel' is missing name in configuration, using id
Repository 'epel' is missing name in configuration, using id
Repository epel is listed more than once in the configuration
Undoing transaction 9, from Fri Apr 21 06:12:21 2017
    Install     apr-util-devel-1.5.2-6.el7.x86_64       @centos7
    Dep-Install cyrus-sasl-devel-2.1.26-20.el7_2.x86_64 @centos7
    Dep-Install expat-devel-2.1.0-8.el7.x86_64          @centos7
    Dep-Install openldap-devel-2.4.40-13.el7.x86_64     @centos7
Remove  4 Packages

Installed size: 5.1 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : apr-util-devel-1.5.2-6.el7.x86_64                                       1/4 
  Erasing    : openldap-devel-2.4.40-13.el7.x86_64                                     2/4 
  Erasing    : expat-devel-2.1.0-8.el7.x86_64                                          3/4 
  Erasing    : cyrus-sasl-devel-2.1.26-20.el7_2.x86_64                                 4/4 
  Verifying  : cyrus-sasl-devel-2.1.26-20.el7_2.x86_64                                 1/4 
  Verifying  : apr-util-devel-1.5.2-6.el7.x86_64                                       2/4 
  Verifying  : openldap-devel-2.4.40-13.el7.x86_64                                     3/4 
  Verifying  : expat-devel-2.1.0-8.el7.x86_64                                          4/4 

Removed:
  apr-util-devel.x86_64 0:1.5.2-6.el7       cyrus-sasl-devel.x86_64 0:2.1.26-20.el7_2      
  expat-devel.x86_64 0:2.1.0-8.el7          openldap-devel.x86_64 0:2.4.40-13.el7          

Complete!

日志 /var/log/yum.log

 

安裝及升級本地程序包:

yum localinstall rpmfile1 [rpmfile2] […]

( install 替代)

yum localupdate rpmfile1 [rpmfile2] […]

( update 替代)

包組管理的相關命令:

yum groupinstall group1 [group2] […]

yum groupupdate group1 [group2] […]

yum grouplist [hidden] [groupwildcard] […]

yum groupremove group1 [group2] […]

yum groupinfo group1 […]

 

yum的命令行選項:

–nogpgcheck :禁止進行gpg check

-y: 自動回答為“yes

-q:靜默模式

–disablerepo=repoidglob :臨時禁用此處指定的repo

–enablerepo=repoidglob :臨時啟用此處指定的repo

–noplugins:禁用所有插件

 

系統光盤yum 倉庫

系統安裝光盤作為本地yum 倉庫:

ü (1)  掛載光盤至某目錄,例如/media/cdrom

# mount /dev/cdrom /media/cdrom

ü (2)  創建配置文件

[CentOS7]

name=

baseurl=

gpgcheck=

enabled=

創建yum 倉庫:

createrepo [options] <directory>

 

程序包編譯

程序包編譯安裝:

Application-VERSION-release.src.rpm –>  安裝后,使用rpmbuild 命令制作成二進制格式的rpm 包,而后再安裝

源代碼–> 預處理–> 編譯–> 匯編–> 鏈接–> 執行

源代碼組織格式:

多文件:文件中的代碼之間,很可能存在跨文件依賴關系

C 、C++ make  項目管理器

configure –> Makefile.in –> makefile

Java: maven

 

編譯安裝

C 語言源代碼編譯安裝三步驟

       1 、./configure

(1)  通過選項傳遞參數,指定啟用特性、安裝路徑等;執行時會參考用戶的指定以及makefile.in 文件生成makefile

(2)  檢查依賴到的外部環境,如依賴的軟件包

2 、make 根據makefile 文件,構建應用程序

3 、make install 復制文件到相應路徑

開發工具:

autoconf:  生成configure 腳本

automake :生成Makefile.in

注意:安裝前查看INSTALL README

開源程序源代碼的獲?。?/p>

官方自建站點:

apache.org (ASF Apache Software Foundation)

mariadb.org

代碼托管:

SourceForge.net

Github.com

Code.google.com

c/c++ 編譯器: gcc (GNU C Complier)

編譯C 源代碼:

準備: 提供開發工具及開發環境

開發工具:make, gcc

開發環境:開發庫,頭文件

glibc :標準庫

實現:通過 “包組”提供開發組件

CentOS 6:

Development Tools

Server Platform Development

CentOS 7:

Development Tools

Development and Creative Workstation

第一步:configure 腳本

選項:指定安裝位置、指定啟用的特性

–help:  獲取其支持使用的選項

選項分類:

安裝路徑設定:

–prefix=/PATH:  指定默認安裝位置, 默認為/usr/local/

–sysconfdir=/PATH :配置文件安裝位置

System types:支持交叉編譯

Optional Features:  可選特性

–disable-FEATURE

–enable-FEATURE[=ARG]

Optional Packages:  可選包

–with-PACKAGE[=ARG], 依賴包

–without-PACKAGE, 禁用依賴關系

第二步:make

第三步:make install

安裝后的配置:

(1)  二進制程序目錄導入至PATH 環境變量中

編輯文件/etc/profile.d/NAME.sh

export PATH=/PATH/TO/BIN:$PATH

(2)  導入庫文件路徑

編輯/etc/ld.so.conf.d/NAME.conf

添加新的庫文件所在目錄至此文件中

讓系統重新生成緩存:

ldconfig [-v]

(3)  導入頭文件

基于鏈接的方式實現:

ln -sv

       (4)  導入幫助手冊

編輯/etc/man.config|man_db.conf 文件

添加一個MANPATH

原創文章,作者:Linux.rookie,如若轉載,請注明出處:http://www.www58058.com/73910

(0)
Linux.rookieLinux.rookie
上一篇 2017-04-23 19:46
下一篇 2017-04-23 19:58

相關推薦

  • CentOS6/7下不關機識別新添加的scsi硬盤

    1)需求說明 在虛擬機中,我們在服務器開機的狀態下添加新的磁盤或者說從存儲上映射某個LUN區域給服務器,不重啟系統的情況下,往往不能夠直接識別到磁盤,在遇到這種情況的時候,我們可以讓系統重新掃描讓服務器重新識別到磁盤。 2)處理步驟 下面看一下在系統不重啟的情況,如何讓系統認識新的磁盤,并能對其分區與格式化 1、在開機狀態下新增磁盤 2、執行下面的命令 ec…

    Linux干貨 2016-07-22
  • 第二周作業

    一、文件管理命令以及演示方法  1.1. mkdir命令     作用:創建文件夾     基本用法:mkdir [OPTION]… DIRECTORY…     參數:   &nbsp…

    Linux干貨 2016-08-22
  • linux文件管理命令與命令行展開

    linux文件管理命令與命令行展開

    2017-12-11
  • ?iptables簡單介紹

    iptables簡單介紹 什么是防火墻? 防火墻是工作在主機或網絡邊緣,能夠對其所匹配到的報文根據事先定義好的規則作出相應處理的組件,可以是軟件,也可以是硬件,還能軟硬結合實現。 UNIX/Linux中對防火墻的實現 早期在openBSD中通過內核中的ipfw實現簡單的數據報過濾功能、后來在Linux 2.2內核中使用ipchains來取代,意為鏈、后來在L…

    Linux干貨 2016-03-31
  • Trap命令簡介

     Trap命令簡介     一、基本概念  trap是一個shell內建命令,它用來在腳本中指定信號如何處理。比如,按Ctrl+C會使腳本終止執行,實際上系統發送了SIGINT信號給腳本進程,SIGINT信號的默認處理方式就是退出程序。如果要在Ctrl +C不退出程序,那么就得使用trap命令來指定一下SIGINT的處…

    Linux干貨 2015-05-11
  • Centos 7 之systemd

    Centos 7 之systemd systemd POST –> Boot Sequence –> Bootloader –> kernel + initramfs(initrd) –> rootfs –> /sbin/init init: CentOS 5: Sys…

    Linux干貨 2016-09-23

評論列表(1條)

  • renjin
    renjin 2017-04-28 10:32

    主要對linux下的軟件包管理進行了詳細的介紹,內容總結的非常詳細,排版也很好。現在你可以把博客的篇數再往上提一下了。

欧美性久久久久