Linux的软件包管理
此博客的环境任意。
主题Linux的软件包管理
一软件管理工具
1编译安装 2rpm包管理 3yum管理
二软件运行和编译
1ABI 应用程序的二进制接口
ABI:Application Binary Interface 应用程序的二进制接口。
一个二进制程序编好了,要在操作系统上跑,就要符合接口标准。
Windows与Linux不兼容。因为二进制程序的格式不同。
ELF(Executable and Linkable Format)是linux的。PE(Portable Executable)是windows的。
注意我现在使用图形化界面的虚拟机
[root@centos71 ~]# ll
total 8
-rw-------. 1 root root 1922 Jan 10 12:15 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Jan 10 14:19 Desktop
drwxr-xr-x. 2 root root 6 Jan 10 14:19 Documents
drwxr-xr-x. 2 root root 6 Jan 10 14:19 Downloads
-rw-r--r--. 1 root root 1953 Jan 10 12:45 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 6 Jan 10 14:19 Music
drwxr-xr-x. 2 root root 6 Jan 10 14:19 Pictures
drwxr-xr-x. 2 root root 6 Jan 10 14:19 Public
drwxr-xr-x. 2 root root 6 Jan 10 14:19 Templates
drwxr-xr-x. 2 root root 6 Jan 10 14:19 Videos
[root@centos71 ~]# ls
anaconda-ks.cfg Desktop Documents Downloads initial-setup-ks.cfg Music Pictures Public Templates Videos
Linux的应用程序的二进制接口
ELF(Executable and Linkable Format)是Linux的格式
[root@centos71 ~]# file /bin/cat
/bin/cat: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=797f79d6d2dc5a84cdc3c21df400f65569ce9a92, stripped
windows的应用程序的二进制接口
拷贝windows里面的ocam软件到虚拟机上
如果要想在windows里面运行Linux程序或者在linux里面运行windows程序就要使用到虚拟化了。
库级别的虚拟化:Linux: WINE,Windows: Cywin
[root@centos71 ~]# rz [root@centos71 ~]# ls
anaconda-ks.cfg Desktop Documents Downloads initial-setup-ks.cfg Music oCam.exe Pictures Public Templates Videos
[root@centos71 ~]# file *.exe
oCam.exe: PE32 executable (GUI) Intel 80386, for MS Windows
2API:Application Programming Interface
在Linux里面写操作系统程序都是用C语言。写的文本要解析成二进制才能在操作系统上运行。
POSIX:Portable OS
处理的过程:程序源代码 --> 预处理 --> 编译 --> 汇编 --> 链接
静态编译:.a
动态编译:.so
像经常使用到的命令实际上是二进制的程序。都是按照上面的处理过程生成的。
[root@centos71 ~]# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs),
for GNU/Linux 2.6.32, BuildID[sha1]=c5ad78cfc1de12b9bb6829207cececb990b3e987, stripped
[root@centos71 ~]# file /bin/mv
/bin/mv: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs),
for GNU/Linux 2.6.32, BuildID[sha1]=68e3aede2af1dadfbfddc9c44bb6b73e9f53dbfb, stripped
[root@centos71 ~]# file /bin/rmdir
/bin/rmdir: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs),
for GNU/Linux 2.6.32, BuildID[sha1]=1c559c20eca21dfc2ec31fffbdf6c5700b29911e, stripped
三二进制应用程序
1二进制应用程序的组成部分
二进制应用程序的组成部分:二进制文件、库文件、配置文件、帮助文件
注意库不能用程序也就不能运行了。大型的软件就有专门的配置文件。配置文件相当于命令的选项功能。
比如bash就有配置文件,家目录里面的都是。
[root@centos71 ~]# ls -a
. anaconda-ks.cfg .bash_logout .bashrc .config .dbus Documents .esd_auth
initial-setup-ks.cfg Music Pictures .tcshrc Videos .Xauthority
.. .bash_history .bash_profile .cache .cshrc Desktop Downloads .ICEauthority .local
oCam.exe Public Templates .viminfo
帮助文件一般都有的,即使是ls都有。
除此之外还有其他的文件,比如数据文件。比如安装web服务器软件,对外提供web服务就要提供网页这样的文件。日志文件,记录事件的发生。
在Linux上安装软件最开始的时候是源码编译。c语言的脚本要使用gcc工具编译成二进制才能运行。
为了降低普通用户使用软件的难度,各个发行版就发行了软件包的管理器,对软件管理起来,不需要进行编译就可以运行软件。
就像在windows上打开安装软件一直安装下去就可以了。在Linux里面都是以统一的文件后缀来组织这些软件的。
2二进制程序所依赖的库文件
二进制程序运行的时候是要依赖一些库的
在系统正常使用的库文件时,会自动的把库文件加载到内存中。
ldd /PATH/TO/BINARY_FILE
[root@centos71 ~]# ldd /bin/cat
linux-vdso.so.1 => (0x00007ffc7b2b6000)
libc.so.6 => /lib64/libc.so.6 (0x00007f0a60de1000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0a611ae000)
[root@centos71 ~]# ll /lib64/libc.so.6
lrwxrwxrwx. 1 root root 12 Jan 10 11:45 /lib64/libc.so.6 -> libc-2.17.so
3管理及查看本机装载的库文件
注意这个子目录来说下个博客,接到这里了。
ldconfig 加载库文件
/sbin/ldconfig -p: 显示本机已经缓存的所有可用库文件名及文件路径映射关系
ldconfig -v 查看所有正在使用的加载到内存的库文件。
[root@centos71 ~]# ldconfig -v | wc
ldconfig: Can't stat /libx32: No such file or directory
ldconfig: Path `/usr/lib' given more than once
ldconfig: Path `/usr/lib64' given more than once
ldconfig: Can't stat /usr/libx32: No such file or directory
959 2867 41578
[root@centos71 ~]# ldconfig -v | head
ldconfig: Can't stat /libx32: No such file or directory
ldconfig: Path `/usr/lib' given more than once
ldconfig: Path `/usr/lib64' given more than once
ldconfig: Can't stat /usr/libx32: No such file or directory
/usr/lib64/dyninst:
libsymtabAPI.so.9.3 -> libsymtabAPI.so.9.3.1
libsymLite.so.9.3 -> libsymLite.so.9.3.1
libstackwalk.so.9.3 -> libstackwalk.so.9.3.1
libpcontrol.so.9.3 -> libpcontrol.so.9.3.1
libpatchAPI.so.9.3 -> libpatchAPI.so.9.3.1
libparseAPI.so.9.3 -> libparseAPI.so.9.3.1
libinstructionAPI.so.9.3 -> libinstructionAPI.so.9.3.1
libdyninstAPI_RT.so.9.3 -> libdyninstAPI_RT.so.9.3.1
libdyninstAPI.so.9.3 -> libdyninstAPI.so.9.3.1
配置文件:/etc/ld.so.conf, /etc/ld.so.conf.d/*.conf
缓存文件:/etc/ld.so.cache
如果做了第三方的模块文件,就是后缀是so的文件。要让其他人使用就要加载到内存里面让别人调用。
可以写到配置文件/etc/ld.so.conf.d下面建立一个以conf结尾的文件。
可以查参考里面已经就有的文件。
自己做了软件,放在了规定的文件路径下,那么就在/etc/ld.so.conf.d建一个conf结尾的文件,在这个文件里面写上路径,系统就可以找到了。
这些库文件可以找到就是生成了独立的配置文件。
[root@centos71 app]# cd /etc/ld.so.conf.d/
[root@centos71 ld.so.conf.d]# ls
dyninst-x86_64.conf kernel-3.10.0-862.el7.x86_64.conf libiscsi-x86_64.conf mariadb-x86_64.conf
[root@centos71 ld.so.conf.d]# cat mariadb-x86_64.conf 写的是路径。
/usr/lib64/mysql
[root@centos71 ld.so.conf.d]# ls /usr/lib64/mysql显示路径实际上显示的就是文件
libmysqlclient.so.18 libmysqlclient.so.18.0.0 plugin
[root@centos71 ld.so.conf.d]# ll /usr/lib64/mysql
total 3064
lrwxrwxrwx. 1 root root 24 Jan 10 11:48 libmysqlclient.so.18 -> libmysqlclient.so.18.0.0
-rwxr-xr-x. 1 root root 3135672 Aug 5 2017 libmysqlclient.so.18.0.0
drwxr-xr-x. 2 root root 54 Jan 10 11:48 plugin
打开主配置文件,也就是包含了他下面的配置文件。
[root@centos71 ld.so.conf.d]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf [root@centos71 ld.so.conf.d]# cat /etc/ld.so.conf.d/*
/usr/lib64/dyninst
# Placeholder file, no vDSO hwcap entries used in this kernel.
/usr/lib64/iscsi
/usr/lib64/mysql
四程序包管理器
1程序包管理器的类型
功能:将编译好的应用程序的各组成文件打包一个或几个程序包文件,从而方便快捷地实现程序包的安装、卸载、查询、升级和校验等管理操作
debian:deb文件, dpkg包管理器。redhat: rpm文件, rpm包管理器
rpm: 这是早期的名称Redhat Package Manager。
里面包含了很多的文件,我们只要记住命令rpm就可以安装软件了。
除了红帽,其他的很多发行版都支持rpm后缀的软件。
因为很多发行版都使用了,成为了标准了就表示成了RPM Package Manager。
2包命名规范
源代码:name-VERSION.tar.gz|bz2|xz
VERSION: major.minor.release
使用rpm对软件包进行管理
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
3包的分类和拆包
在包很多的情况下可能会进行拆包,也就是对包进行拆分。这样以后只要把要用的包安装上就可以了,不会占用那么多的空间。
包之间可能存在依赖关系,甚至循环依赖。比如要安装A包就会提示把B包安装上。
Application-VERSION-ARCH.rpm: 主包
Application-devel-VERSION-ARCH.rpm 开发子包
Application-utils-VERSION-ARHC.rpm 其它子包
Application-libs-VERSION-ARHC.rpm 其它子包
4解决依赖包管理工具
yum:rpm包管理器的前端工具。一旦发现有依赖性的包自动就会安装上依赖的包。这样可以解决循环依赖的问题。
apt-get:deb包管理器前端工具
zypper: suse上的rpm前端管理工具
dnf: Fedora 18+ rpm包管理器前端管理工具。这个未来可能会使用。
最新文章
- Zookeeper 的学习与运用
- 17243 Huzi酱和他的俄罗斯套娃(贪心)
- MVC Actionlink 参数说明
- docker-3 基础命令
- 4.mybatis属性和表的列名不相同时的处理方法
- 后台向前台传递entity的list然后构筑combobox的方法(easyui)
- Netsharp快速入门(之8) 基础档案(工作区2 设置商品主列表、规格细列表、商品表单、查询)
- 改ext界面
- [iOS Animation]CALayer-图层时间
- MalformedObjectNameException: Invalid character '' in value part of property
- Jquery基础添加删除内容
- CSharpGL(48)用ShadowVolume画模型的影子
- Swift与C++混编 OpenCV初体验 图片打码~
- [Swift]LeetCode761. 特殊的二进制序列 | Special Binary String
- 页面添加锚点后如何点击不改变URL?
- 有关在Eclipse中安装STS(Spring Tool Suite)的若干问题总结
- January 16th, 2018 Week 03rd Tuesday
- ELK之写入MySQL数据库
- 触发器 视图 存储过程 mysql常用函数
- LeetCode 48. Rotate Image (C++)
热门文章
- [CSP-S模拟测试]:Read(数学)
- 2018-2019-20175203 实验二 《Java面向对象程序设计》
- Gym-100676F Palindrome
- linux设备驱动第二篇:构造和运行模块
- linux设备驱动学习笔记--内核调试方法之printk
- 杂项:电子表格程序-u
- xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
- java对象实例化 静态块,对象块,构造函数执行顺序
- 解决让刷新页面时不提示 ";重试或取消”对话框
- java自学基础、项目实战网站推荐