07 Linux软件包管理
Linux软件包管理
- rpm软件包管理
- Yum软件包管理
- Dnf软件包管理
- 源码编译安装
准备工作
挂载iso镜像
将光驱挂载到系统中
[root@myserver dev]# mount /dev/sr0 /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@myserver dev]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 884M 0 884M 0% /dev
tmpfs 901M 0 901M 0% /dev/shm
tmpfs 901M 9.8M 891M 2% /run
tmpfs 901M 0 901M 0% /sys/fs/cgroup
/dev/mapper/cl_myserver-root 17G 5.2G 12G 31% /
/dev/sdb1 5.0G 68M 5.0G 2% /data/sdb1
/dev/sda1 976M 194M 716M 22% /boot
tmpfs 181M 16K 181M 1% /run/user/0
tmpfs 181M 1.2M 179M 1% /run/user/42
/dev/sr0 6.7G 6.7G 0 100% /mnt
Rpm软件包管理
windows : exe ; mac OS : dmg ; Linux: rpm
当我们的应用可以直接安装的时候建议使用rpm直接安装。 但是当我们的应用需要依赖于其他的包的时候rpm就会变得很难受。
rpm 命令使用方法
rpm -qa | grep xz : 查看所有已经安装的包
rpm -ivh xxx.rpm : 安装xxx.rpm
rpm -e xxx : 卸载 xxx
rpm -Uvh xxx.rpm : 更新xxx.rpm
cd /mnt/BaseOS/Packages## 查找包是否已经安装
[root@myserver Packages]# rpm -qa | grep xz
xz-libs-5.2.4-3.el8.x86_64
xz-5.2.4-3.el8.x86_64## 获取相关的RPM包
[root@myserver Packages]# ls | grep xz
xz-5.2.4-3.el8.x86_64.rpm
xz-devel-5.2.4-3.el8.i686.rpm
xz-devel-5.2.4-3.el8.x86_64.rpm
xz-libs-5.2.4-3.el8.i686.rpm
xz-libs-5.2.4-3.el8.x86_64.rpm## 开始安装
[root@myserver Packages]# rpm -ivh xz-devel-5.2.4-3.el8.x86_64.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...1:xz-devel-5.2.4-3.el8 ################################# [100%]## 验证是否安装成功
[root@myserver Packages]# rpm -qa | grep xz
xz-libs-5.2.4-3.el8.x86_64
xz-5.2.4-3.el8.x86_64
xz-devel-5.2.4-3.el8.x86_64## 卸载
[root@myserver Packages]# rpm -e xz-devel-5.2.4-3.el8.x86_64
[root@myserver Packages]# rpm -qa | grep xz
xz-libs-5.2.4-3.el8.x86_64
xz-5.2.4-3.el8.x86_64
Yum软件包管理工具
yum仓库概念=== yum源
源配置需要的是一个xxx.repo文件, /etc/yum.repos.d/
yum remove xz-devel: 卸载xz-devel
yum -y install xz-devel : 安装xz-devel -y不用交互方式。
yum update xz-devel: 更新xz-devel
yum clean all : 清理缓存
操作前准备: 备份初始源
[root@myserver yum.repos.d]# mkdir bak
[root@myserver yum.repos.d]# ls
bak CentOS-Debuginfo.repo CentOS-Media.repo
CentOS-AppStream.repo CentOS-Devel.repo CentOS-PowerTools.repo
CentOS-Base.repo CentOS-Extras.repo CentOS-Sources.repo
CentOS-centosplus.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-HA.repo
[root@myserver yum.repos.d]# mv *.repo bak/
[root@myserver yum.repos.d]# ls
bak
yum源文件格式
[BaseOS] ## 仓库名称
name=CentOS-$releasever - Base ## 仓库描述
baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/ ## 源地址 【在线HTTP|FILE本地文件】
gpgcheck=1 ## 证书验证
enabled=1 ## 是否启动
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
配置本地YUM
[myrepo]
name=My first repo test.
baseurl=file:///mnt/BaseOS/
gpgcheck=0
enabled=1
[root@myserver ~]# cd /etc/yum.repos.d/
[root@myserver yum.repos.d]# ls
bak
[root@myserver yum.repos.d]# vim myrepo.repo
[root@myserver yum.repos.d]# ls
bak myrepo.repo
[root@myserver ~]# yum repolist
repo id repo name
myrepo My first repo test.
[root@myserver ~]# rpm -qa | grep xz
xz-libs-5.2.4-3.el8.x86_64
xz-5.2.4-3.el8.x86_64
[root@myserver ~]# yum install xz*
My first repo test. 24 MB/s | 2.2 MB 00:00
Last metadata expiration check: 0:00:01 ago on Sun 21 Jun 2020 10:00:03 PM EDT.
Package xz-5.2.4-3.el8.x86_64 is already installed.
Package xz-libs-5.2.4-3.el8.x86_64 is already installed.
Dependencies resolved.
===================================================================================Package Architecture Version Repository Size
===================================================================================
Installing:xz-devel x86_64 5.2.4-3.el8 myrepo 62 kTransaction Summary
===================================================================================
Install 1 PackageTotal size: 62 k
Installed size: 202 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing : 1/1 Installing : xz-devel-5.2.4-3.el8.x86_64 1/1 Running scriptlet: xz-devel-5.2.4-3.el8.x86_64 1/1 Verifying : xz-devel-5.2.4-3.el8.x86_64 1/1
Installed products updated.Installed:xz-devel-5.2.4-3.el8.x86_64 Complete!
[root@myserver ~]# rpm -qa | grep xz
xz-devel-5.2.4-3.el8.x86_64
xz-libs-5.2.4-3.el8.x86_64
xz-5.2.4-3.el8.x86_64
[root@myserver ~]# yum remove xz-devel
Dependencies resolved.
================================================================================================Package Architecture Version Repository Size
================================================================================================
Removing:xz-devel x86_64 5.2.4-3.el8 @myrepo 202 kTransaction Summary
================================================================================================
Remove 1 PackageFreed space: 202 k
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing : 1/1 Erasing : xz-devel-5.2.4-3.el8.x86_64 1/1 Running scriptlet: xz-devel-5.2.4-3.el8.x86_64 1/1 Verifying : xz-devel-5.2.4-3.el8.x86_64 1/1
Installed products updated.Removed:xz-devel-5.2.4-3.el8.x86_64 Complete!
在线YUM源
备份本地yum,创建新的在线yum源
[root@myserver ~]# cd /etc/yum.repos.d/
[root@myserver yum.repos.d]# ls
bak myrepo.repo
[root@myserver yum.repos.d]# mv myrepo.repo myrepo.repo~
[root@myserver yum.repos.d]# ls
bak myrepo.repo~
[root@myserver yum.repos.d]# vim myrepo.repo
[myrepo]
name=My first repo test.
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/8/BaseOS/x86_64/os/
gpgcheck=0
enabled=1
[root@myserver yum.repos.d]# yum -y install xz-devel
My first repo test. 537 kB/s | 2.2 MB 00:04
Last metadata expiration check: 0:00:01 ago on Sun 21 Jun 2020 10:09:55 PM EDT.
Dependencies resolved.
================================================================================================Package Architecture Version Repository Size
================================================================================================
Installing:xz-devel x86_64 5.2.4-3.el8 myrepo 62 kTransaction Summary
================================================================================================
Install 1 PackageTotal download size: 62 k
Installed size: 202 k
Downloading Packages:
xz-devel-5.2.4-3.el8.x86_64.rpm 105 kB/s | 62 kB 00:00
------------------------------------------------------------------------------------------------
Total 104 kB/s | 62 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing : 1/1 Installing : xz-devel-5.2.4-3.el8.x86_64 1/1 Running scriptlet: xz-devel-5.2.4-3.el8.x86_64 1/1 Verifying : xz-devel-5.2.4-3.el8.x86_64 1/1
Installed products updated.Installed:xz-devel-5.2.4-3.el8.x86_64 Complete!
FAQ
[root@myserver yum.repos.d]# yum -y install xz-devel
My first repo test. 0.0 B/s | 0 B 00:00
Errors during downloading metadata for repository 'myrepo':- Curl error (6): Couldn't resolve host name for https://mirrors.tuna.tsinghua.edu.cn/centos/8/BaseOS/x86_64/os/repodata/repomd.xml [Could not resolve host: mirrors.tuna.tsinghua.edu.cn]
Error: Failed to download metadata for repo 'myrepo': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
[root@myserver yum.repos.d]# ping www.baidu.com
ping: www.baidu.com: Name or service not known## 重新获取地址信息
[root@myserver yum.repos.d]# dhclient
[root@myserver yum.repos.d]# ping www.baidu.com
PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data.
64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=1 ttl=56 time=4.68 ms
64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=2 ttl=56 time=4.92 ms
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 2ms
rtt min/avg/max/mdev = 4.675/4.795/4.916/0.138 ms
Dnf软件包管理工具
DNF是Dandified yum的缩写。DNF也是基于RPM的包管理工具,其首先在Fedora系统中出现,已经成为Fedora系统的默认的包管理工具。
比Yum要简单、消耗更少内容、依赖包解析速度更快
xz-devel
dnf list installed: 列出所有已安装的包
dnf search : 查找包
dnf install: 安装命令
dnf reinstall : 重新安装
dnf download : 下载包
dnf check-update: 检查更新
dnf update : 更新
dnf repolist all : 查看所有可用的源
dnf remove : 卸载软件
dnf clean all : 清除缓存
源码编译安装
创建归档
tar cf 归档名称 文件
tar xf 归档名称 -C 指定解包路径
[root@myserver ~]# tar cf mytestfile.tar a.txt b.txt c.txt
[root@myserver ~]# ls
a b.txt Documents Music Pictures test
anaconda-ks.cfg c.txt Downloads mytestfile Public Videos
a.txt Desktop initial-setup-ks.cfg mytest.txt Templates
[root@myserver ~]# file mytestfile.tar
mytestfile: POSIX tar archive (GNU)
[root@myserver ~]# tar xf mytestfile.tar -C /opt/
[root@myserver ~]# ls /opt/
a.txt b.txt c.txt
压缩包 tar.gz
[root@myserver ~]# tar zcf mytestfile.tar.gz a.txt b.txt c.txt
[root@myserver ~]# ls
a c.txt initial-setup-ks.cfg mytest.txt test
anaconda-ks.cfg Desktop Music Pictures Videos
a.txt Documents mytestfile Public
b.txt Downloads mytestfile.tar.gz Templates
[root@myserver ~]# file mytestfile.tar.gz
mytestfile.tar.gz: gzip compressed data, last modified: Mon Jun 22 12:38:35 2020, from Unix, original size 10240
[root@myserver ~]# tar zxf mytestfile.tar.gz -C /mnt/
[root@myserver ~]# ls /mnt/
a.txt b.txt c.txt hgfs
源码编译安装过程
- 下载应用的源码包
- wget 下载源码包
- 解压源码包
- 默认解压路径 : /usr/local/
- tar zxf xxxx -C /usr/local
- 执行配置文件
- 执行编译
- 执行编译安装
[root@myserver ~]# wget http://zlib.net/zlib-1.2.11.tar.gz
--2020-06-22 08:44:02-- http://zlib.net/zlib-1.2.11.tar.gz
Resolving zlib.net (zlib.net)... 68.66.224.49
Connecting to zlib.net (zlib.net)|68.66.224.49|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 607698 (593K) [application/x-gzip]
Saving to: \u2018zlib-1.2.11.tar.gz\u2019zlib-1.2.11.tar.gz 100%[=======================>] 593.46K 11.4KB/s in 49s 2020-06-22 08:44:47 (12.2 KB/s) - \u2018zlib-1.2.11.tar.gz\u2019 saved [607698/607698]
[root@myserver ~]# ls
a c.txt initial-setup-ks.cfg mytest.txt test
anaconda-ks.cfg Desktop Music Pictures Videos
a.txt Documents mytestfile Public zlib-1.2.11.tar.gz
b.txt Downloads mytestfile.tar.gz Templates
[root@myserver ~]# tar zxf zlib-1.2.11.tar.gz -C /usr/local/
[root@myserver ~]# ls /usr/local/
bin etc games include lib lib64 libexec sbin share src zlib-1.2.11
[root@myserver ~]# cd /usr/local/zlib-1.2.11/
[root@myserver zlib-1.2.11]# ls
adler32.c examples inflate.c README zlib.3
amiga FAQ inflate.h test zlib.3.pdf
ChangeLog gzclose.c inftrees.c treebuild.xml zlib.h
CMakeLists.txt gzguts.h inftrees.h trees.c zlib.map
compress.c gzlib.c Makefile trees.h zlib.pc.cmakein
configure gzread.c Makefile.in uncompr.c zlib.pc.in
contrib gzwrite.c make_vms.com watcom zutil.c
crc32.c INDEX msdos win32 zutil.h
crc32.h infback.c nintendods zconf.h
deflate.c inffast.c old zconf.h.cmakein
deflate.h inffast.h os400 zconf.h.in
doc inffixed.h qnx zlib2ansi
[root@myserver zlib-1.2.11]#
开始编译 https://www.nginx.cn/install
编译之前首先需要安装gcc gcc-c++ 编译器
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++`
[root@myserver zlib-1.2.11]# ./configure
Checking for gcc...
Checking for shared library support...
Building shared library libz.so.1.2.11 with gcc.
Checking for size_t... Yes.
Checking for off64_t... Yes.
Checking for fseeko... Yes.
Checking for strerror... Yes.
Checking for unistd.h... Yes.
Checking for stdarg.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
Checking for vsnprintf() in stdio.h... Yes.
Checking for return value of vsnprintf()... Yes.
Checking for attribute(visibility) support... Yes.
[root@myserver zlib-1.2.11]# make
[root@myserver zlib-1.2.11]# make install
rm -f /usr/local/lib/libz.a
cp libz.a /usr/local/lib
chmod 644 /usr/local/lib/libz.a
cp libz.so.1.2.11 /usr/local/lib
chmod 755 /usr/local/lib/libz.so.1.2.11
rm -f /usr/local/share/man/man3/zlib.3
cp zlib.3 /usr/local/share/man/man3
chmod 644 /usr/local/share/man/man3/zlib.3
rm -f /usr/local/lib/pkgconfig/zlib.pc
cp zlib.pc /usr/local/lib/pkgconfig
chmod 644 /usr/local/lib/pkgconfig/zlib.pc
rm -f /usr/local/include/zlib.h /usr/local/include/zconf.h
cp zlib.h zconf.h /usr/local/include
chmod 644 /usr/local/include/zlib.h /usr/local/include/zconf.h
07 Linux软件包管理相关推荐
- linux软件包管理详解
linux软件包管理 在windows下安装软件很简单,大多数软件都只需要按照提示完成安装操作.但是,在linux下安装软件稍微复杂了一点,需要用到命令行工具.下面通过在Red Hat Enterpr ...
- linux软件包管理之rpm 、yum基本使用
linux软件包管理之rpm .yum基本使用 一.RPM RPM是RedHat Package Manager(RedHat软件包管理工具)的缩写,这一文件格式名称虽然打上了RedHat的标志,但是 ...
- Linux_09 Linux软件包管理 rpm与yum
Linux软件包管理 rpm与yum 文件的压缩与打包 rpm安装软件 yum安装删除软件 yum进阶 一. 文件的打包 与压缩 压缩:指通过某些算法,将文件尺寸进行相应的缩小,同时不损失文件的内容. ...
- CentOS6.4之Linux软件包管理
二进制软件包管理(RPM.YUM) 源代码包安装 脚本安装(Shell或Java脚本) Debian系Linux软件包管理简介 一.RPM包管理 RPM软件包的一个例子: sudo-1.8.6p3-7 ...
- linux软件包管理学习归档-2020-0624
linux软件包管理 这个知识点老师讲过,并且你还笑过,但是用的时候就是没想起来------罗翔 from:来源是阿里云大学上的免费课程,马哥教育的Linux软件包安装和yum仓库实战: P.S.何所 ...
- Linux 软件包管理
Linux 软件包管理 1. 查看linux 文件类型,查看windows文件类型 [root@www /]# file /bin/cat /bin/cat: ELF 64-bit LSB execu ...
- Linux软件包管理之源码包、脚本安装包
目录 1.源码包和RPM包的区别 RPM包和源码包默认安装位置: 由于安装位置不同带来的影响 2.源码包安装 ①.安装准备 ②.安装注意事项 ③.安装源码包 3.源码包卸载 4.脚本安装包 5.总结 ...
- 【linux】一篇全面的linux软件包管理的总结
一篇全面的linux软件包管理的总结 文章目录 一篇全面的linux软件包管理的总结 零.开篇 一.查看软件包信息 (1-1)使用aptitude查看linux系统上安装了哪些软件包. (1-2)使用 ...
- Linux软件包管理-rpm、yum
Linux软件包管理 软件包是什么?软件包顾名思义就是将应用程序.配置文件和数据打包的产物. 所有的linux发行版都采用了某种形式的软件包系统,这使得linux软件管理和在windows下一样方便, ...
最新文章
- [数据结构] 时间复杂度计算
- 19. 邮件提醒(发送邮件)
- JZOJ 5397. 【NOIP2017提高A组模拟10.6】Biology
- 分库分表下极致的优化
- edge浏览器下载位置设置
- 模块的封装性分析-读书笔记
- 协同过滤算法(天池竞赛试题)
- 《C#线程参考手册》读书笔记(三):.NET中的线程池
- 将ubuntu的home迁移至第二块磁盘
- 1 Linux防火墙设置
- LaTeX —— 特殊符号与数学字体
- UIImage保存到相册
- Mybatis系列(四)注解
- 在哪一类期刊中发表论文最难,SCI、SSCI、还是AHCI?
- 计算机弹琴游戏,电脑键盘钢琴软件(弹钢琴小游戏)
- 网站建设网页设计小技巧分享
- Android studio 图片按钮
- ECharts热力图指定颜色
- 怪物之心无法触发_异度之刃2解锁稀有异刃力男支线怪物之心BOSS位置攻略
- 如何查看电脑上面的maven版本?
热门文章
- 图书管理销售系统概要分析,接口设计部分
- 哪款降噪耳机好?入耳式降噪耳机排行榜
- Spark学习-事件日志EventLog
- 【系统性学习】Linux Shell易忘重点整理
- 自定义控件学习笔记(五)Canvas 对绘制的辅助——范围裁切和几何变换
- MySQL 5.7-8.9.3 Optimizer Hints(优化器提示)
- invalid openid hint
- 继续翻译今天的暴雪官网新闻
- 人脸识别、文字识别背后的方法,以及研究的热点和难点
- linux控制终端关机命令,linux定时关机命令?linux立即关机命令?终端切换界面?windows定时关机和linux定时关机的方法(shut...