Linux系统下安装软件包方法(上)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux系统下安装软件包方法(上)相关的知识,希望对你有一定的参考价值。
安装软件包的三种方法
1.rpm工具
2.yum工具 (可以自动安装依赖包)
3.源码包
rpm工具介绍及使用
1.首先挂载光驱:
which-2.20-7.el7.x86_64.rpm #包含包名,版本号,发布版本号,平台
whois-5.1.1-2.el7.x86_64.rpm
wireshark-1.10.14-14.el7.x86_64.rpm
wireshark-gnome-1.10.14-14.el7.x86_64.rpm
wodim-1.1.11-23.el7.x86_64.rpm
2.安装: -ivh
[[email protected] Packages]# rpm -ivh zsh-5.0.2-28.el7.x86_64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:zsh-5.0.2-28.el7 ################################# [100%]
3.升级:-Uvh
[[email protected] Packages]# rpm -Uvh zsh-5.0.2-28.el7.x86_64.rpm
准备中... ################################# [100%]
软件包 zsh-5.0.2-28.el7.x86_64 已经安装
4.卸载:-e
[[email protected] Packages]# rpm -e zsh
5.查询所有安装的包:-qa
[[email protected] Packages]# rpm -qa
open-vm-tools-10.1.5-3.el7.x86_64
grub2-common-2.02-0.64.el7.centos.noarch
kexec-tools-2.0.14-17.el7.x86_64
setup-2.8.71-7.el7.noarch
NetworkManager-tui-1.8.0-9.el7.x86_64
basesystem-10.0-7.el7.centos.noarch
NetworkManager-wifi-1.8.0-9.el7.x86_64
6.查询指定的包是否安装:-q
[[email protected] Packages]# rpm -q zsh
zsh-5.0.2-28.el7.x86_64
7.查询指定包信息: -qi
[[email protected] Packages]# rpm -qi vim-enhanced
Name : vim-enhanced
Epoch : 2
Version : 7.4.160
Release : 2.el7
Architecture: x86_64
Install Date: 2018年01月03日 星期三 15时24分46秒
8.列出包安装的文件: -ql
[roo[email protected] Packages]# rpm -ql vim-enhanced
/etc/profile.d/vim.csh
/etc/profile.d/vim.sh
/usr/bin/rvim
/usr/bin/vim
/usr/bin/vimdiff
/usr/bin/vimtutor
9.查询一个文件是由哪个包安装的: -qf
[[email protected] Packages]# rpm -qf /usr/bin/vim
vim-enhanced-7.4.160-2.el7.x86_64
[[email protected] Packages]# rpm -qf `which cd` #可以先查询命令,在查询由哪个安装的,反引号
bash-4.2.46-28.el7.x86_64
yum工具用法
1.yum可以自动安装依赖包
2.列出可用包:yum list
[[email protected] Packages]# yum list
zenity.x86_64 3.22.0-1.el7 base
zlib.i686 1.2.7-17.el7 base
zlib-devel.i686 1.2.7-17.el7 base
zlib-devel.x86_64 1.2.7-17.el7 base
zlib-static.i686 1.2.7-17.el7 base
zlib-static.x86_64 1.2.7-17.el7 base
zsh.x86_64 5.0.2-28.el7 base
zsh-html.x86_64 5.0.2-28.el7 base
zziplib.i686 0.13.62-5.el7 base
zziplib.x86_64 0.13.62-5.el7 base
3.搜索一个包:
[[email protected] Packages]# yum search vim
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.163.com
* updates: mirrors.tuna.tsinghua.edu.cn
============================ N/S matched: vim ============================
protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers
: descriptions
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System
vim-common.x86_64 : The common files needed by any version of the VIM
: editor
vim-enhanced.x86_64 : A version of the VIM editor which includes recent
: enhancements
vim-filesystem.x86_64 : VIM filesystem layout
vim-minimal.x86_64 : A minimal version of the VIM editor
名称和简介匹配 only,使用“search all”试试。
相对精确的搜索:
[[email protected] Packages]# yum list |grep ‘vim‘
vim-minimal.x86_64 2:7.4.160-2.el7 @anaconda
protobuf-vim.x86_64 2.5.0-8.el7 base
vim-X11.x86_64 2:7.4.160-2.el7 base
vim-common.x86_64 2:7.4.160-2.el7 base
vim-enhanced.x86_64 2:7.4.160-2.el7 base
vim-filesystem.x86_64 2:7.4.160-2.el7 base
4.安装一个包:yum install -y #-y不在询问是否安装,直接安装
5.组显示:
[[email protected] Packages]# yum grouplist
已加载插件:fastestmirror
没有安装组信息文件
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.163.com
* updates: mirrors.tuna.tsinghua.edu.cn
可用的环境分组:
最小安装
基础设施服务器
计算节点
文件及打印服务器
基本网页服务器
虚拟化主机
带 GUI 的服务器
GNOME 桌面
KDE Plasma Workspaces
开发及生成工作站
可用组:
传统 UNIX 兼容性
兼容性程序库
图形管理工具
安全性工具
开发工具
控制台互联网工具
智能卡支持
科学记数法支持
系统管理
系统管理工具
完成
6.组安装:yum groupinstall -y
7.卸载:yum remove -y
8.升级一个包:yum update -y #如果不加包名,所有东西都升级
9.搜索该命令所需要的包:yum provides
[[email protected] Packages]# yum provides "/*/vim"
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.163.com
* updates: mirrors.tuna.tsinghua.edu.cn
base/7/x86_64/filelists_db | 6.7 MB 01:46
extras/7/x86_64/filelists_db | 528 kB 00:18
updates/7/x86_64/filelists_db | 3.0 MB 00:41
cmake-2.8.12.2-2.el7.x86_64 : Cross-platform make system
源 :base
匹配来源:
文件名 :/usr/share/cmake/editors/vim
2:docker-unit-test-1.12.6-48.git0fdc778.el7.centos.x86_64 : Automates
...: deployment of containerized applications - for running unit
...: tests
源 :extras
匹配来源:
文件名 :/var/lib/docker-unit-test/docker-novolume-plugin-385ec70baac3ef356f868f391c8d7818140fbd44/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
文件名 :/var/lib/docker-unit-test/contrib/syntax/vim
文件名 :/var/lib/docker-unit-test/v1.10-migrator-c417a6a022c5023c111662e8280f885f6ac259be/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
文件名 :/var/lib/docker-unit-test/runc-79c3939053c870fbb4de5484d98640d5ba028ef4/Godeps/_workspace/src/github.com/docker/docker/contrib/syntax/vim
yum搭建本地仓库
1.挂载光驱
2.备份文件目录:
[[email protected] ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d.bak
3.删除原有的:
[[email protected] yum.repos.d]# rm -rf ./*
4.创建新的仓库,并添加内容,然后清除缓存:
[[email protected] yum.repos.d]# vi dvd.repo
[[email protected] yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: dvd
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
5.再次yum list 发现yum仓库为dvd:
cdparanoia-libs.x86_64 10.2-17.el7 dvd
cdrdao.x86_64 1.2.3-20.el7 dvd
celt051.x86_64 0.5.1.3-8.el7 dvd
centos-bookmarks.noarch 7-1.el7 dvd
centos-indexhtml.noarch 7-9.el7.centos dvd
certmonger.x86_64 0.78.4-3.el7 dvd
cgdcbxd.x86_64 1.0.2-7.el7 dvd
check.x86_64 0.9.9-5.el7 dvd
图中两处错误
gpgcheck=0
yum clean all
以上是关于Linux系统下安装软件包方法(上)的主要内容,如果未能解决你的问题,请参考以下文章