3.5 7.1-7.5听课笔记

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了3.5 7.1-7.5听课笔记相关的知识,希望对你有一定的参考价值。

Linux下安装软件包的三种方法

 

rpm工具、yum工具、源码包

rpm包:centosredhat等系统下软件安装包叫rpm包,rpm安装路径、文件名通常提前固定好,红帽子公司包管理系统

yum工具:操作对象也是rpm包,但yum会帮用户自动安装有依赖关系的包,类似手机的app store,容易操作

源码包:需要先用编译器将源码包编译为可执行文件,操作难度最大

 

rpm安装路径、文件名通常提前固定好

 

rpm包介绍

 

zip(包名)-3.0(版本号)-11.el7.x86_64(适用于centos764位).rpm

64位平台可以安装32位的包

 

rpm工具用法

 

安装包

[[email protected] Packages]# rpm -ivh zsh-5.0.2-28.el7.x86_64.rpm

准备中...                          ################################# [100%]

正在升级/安装...

   1:zsh-5.0.2-28.el7                 ################################# [100%]

i:inststall v:可视化 h:使显示更人性化(显示安装进度)

 

升级包

rpm -Uvh zsh-5.0.2-28.el7.x86_64.rpm

 

卸载包

[[email protected] Packages]# rpm -e zsh

[[email protected] Packages]#

*卸载时无显示为正常现象,有错误时会有提示

*若多个包依赖于这个包,则需要先卸载这依赖的包再卸载这个被依赖的包

 

查询已安装的包

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

bind-license-9.9.4-50.el7.noarch

postfix-2.10.1-6.el7.x86_64

firewalld-filesystem-0.4.4.4-6.el7.

 

查询单个包是否被安装

[[email protected] Packages]# rpm -q ppp

未安装软件包 ppp

 

查询指定包的信息

[[email protected] Packages]# rpm -qi vim-enhanced

Name        : vim-enhanced

Epoch       : 2

Version     : 7.4.160

Release     : 2.el7

Architecture: x86_64

Install Date: 20180222 星期四 113850

Group       : Applications/Editors

Size        : 2292098

License     : Vim

Signature   : RSA/SHA256, 20170811 星期五 041538, Key ID 24c6a8a7f4a80eb5

Source RPM  : vim-7.4.160-2.el7.src.rpm

Build Date  : 20170802 星期三 084612

Build Host  : c1bm.rdu2.centos.org

Relocations : (not relocatable)

Packager    : CentOS BuildSystem <http://bugs.centos.org>

Vendor      : CentOS

URL         : http://www.vim.org/

Summary     : A version of the VIM editor which includes recent enhancements

Description :

 

查询rpm包安装的文件

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

 

反向查询某个文件由哪个包安装(命令已被安装时使用)

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

*`which cd`表示查询cd的文件路径

 

Yum工具用法

 

yum安装工具可以自动解决依赖关系

 

列出可安装的包的摘要信息

[[email protected] Packages]# yum list 包名、适用系统32/64、平台版本号、仓库名(base)等信息

 

 

[[email protected] yum.repos.d]# ls /etc/yum.repos.d/ 仓库相关目录

CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo

CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo

[[email protected] yum.repos.d]# cat CentOS-Base.repo 与仓库有关的文件

[base]

name=CentOS-$releasever - Base

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra 仓库地址

[email protected] yum.repos.d]# yum search vim 搜索与vim相关的包

已加载插件:fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirrors.zju.edu.cn

 * extras: mirrors.tuna.tsinghua.edu.cn

 * 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”试试。

*使用yum search时不管是包名相关还是描述信息相关只要包与vim有关就会被列出,所以结果不精确

[[email protected] yum.repos.d]# yum list |grep 'vim' yum list中查找vim相关结果

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   

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的才会被列出,vim的部分显示不同的颜色

[[email protected] yum.repos.d]# yum grouplist 列出可用的组

已加载插件:fastestmirror

没有安装组信息文件

Maybe run: yum groups mark convert (see man yum)

Loading mirror speeds from cached hostfile

 * base: mirrors.zju.edu.cn

 * extras: mirrors.tuna.tsinghua.edu.cn

 * updates: mirrors.tuna.tsinghua.edu.cn

可用的环境分组:

   最小安装

   基础设施服务器

   计算节点

   文件及打印服务器

   基本网页服务器

   虚拟化主机

   GUI 的服务器

   GNOME 桌面

   KDE Plasma Workspaces

   开发及生成工作站

可用组:

   传统 UNIX 兼容性

   兼容性程序库

   图形管理工具

   安全性工具

   开发工具

   控制台互联网工具

   智能卡支持

   科学记数法支持

   系统管理

   系统管理工具

完成

[[email protected] yum.repos.d]# 修改语言

[[email protected] yum.repos.d]# yum groupinstall ' Virtualization Host ' 安装组(不加-y则会询问)

[[email protected] yum.repos.d]# yum remove ppp 卸载ppp包时将依赖包也卸载掉(操作较危险)

[[email protected] yum.repos.d]# yum update 升级rpm包(可选是否加-y-y后跟包名,否则将升级系统内所有rpm包及系统本身(内核等的版本),在已经稳定运行的机器上谨慎使用)

 

[[email protected] yum.repos.d]# rpm -ql vim-enhanced 无法查看包安装哪些文件

package vim-enhanced is not installed

[[email protected] yum.repos.d]# rpm -qf /usr/bin/vim 无法查看命令由哪个包安装

error: file /usr/bin/vim: No such file or directory

[[email protected] yum.repos.d]# rpm -qi vim-enhanced 无法显示包信息

package vim-enhanced is not installed

[[email protected] yum.repos.d]# rpm -q ppp

package ppp is not installed

*包被卸载则以上命令无法使用

 

yum搭建本地仓库

 

1. [[email protected] yum.repos.d]# df –h mount下挂载光驱

Filesystem      Size  Used Avail Use% Mounted on

/dev/sda3        28G  1.2G   27G   5% /

devtmpfs        479M     0  479M   0% /dev

tmpfs           489M     0  489M   0% /dev/shm

tmpfs           489M  6.7M  482M   2% /run

tmpfs           489M     0  489M   0% /sys/fs/cgroup

/dev/sda1       197M   97M  100M  50% /boot

tmpfs            98M     0   98M   0% /run/user/0

/dev/sr0        4.3G  4.3G     0 100% /mnt

 

2. [[email protected] yum.repos.d]# rm -f /etc/yum.repos.d/*

[[email protected] yum.repos.d]# vim /etc/yum.repos.d/dvd.repo

 

[dvd] 仓库名字

Name=install dvd 仓库的描述字符串

baseurl=file:///mnt rpm包的位置,即光驱路径

enable=1 是否可用(1可用,0不可用)

gpcheck=0 是否检测

 

[[email protected] yum.repos.d]# yum clean all 清理yum缓存

Failed to set locale, defaulting to C

Loaded plugins: fastestmirror

Cleaning repos: 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

[[email protected] yum.repos.d]#

 

texlive-mptopdf-bin.noarch                 2:svn18674.0-38.20130427_r30134.el7

                                                                          dvd   

仓库名从base变成了dvd

open-vm-tools.x86_64                    10.1.5-3.el7                   @anaconda

*@说明该包已被安装

[[email protected] yum.repos.d]# yum install -y wavpack.x86_64

Failed to set locale, defaulting to C

BDB2053 Freeing read locks for locker 0x1cd: 1487/139759846364992

BDB2053 Freeing read locks for locker 0x1cf: 1487/139759846364992

BDB2053 Freeing read locks for locker 0x1d1: 1487/139759846364992

BDB2053 Freeing read locks for locker 0x1d2: 1487/139759846364992

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

Resolving Dependencies

--> Running transaction check

---> Package wavpack.x86_64 0:4.60.1-9.el7 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

===================================================================================

 Package            Arch              Version                 Repository      Size

===================================================================================

Installing:

 wavpack            x86_64            4.60.1-9.el7            dvd            131 k

 

Transaction Summary

===================================================================================

Install  1 Package

 

Total download size: 131 k

Installed size: 296 k

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : wavpack-4.60.1-9.el7.x86_64                                     1/1

  Verifying  : wavpack-4.60.1-9.el7.x86_64                                     1/1

 

Installed:

  wavpack.x86_64 0:4.60.1-9.el7                                                   

 

Complete!

[[email protected] yum.repos.d]# 安装成功


以上是关于3.5 7.1-7.5听课笔记的主要内容,如果未能解决你的问题,请参考以下文章

Python基础听课笔记

python 听课笔记- 序(鸡汤)

APIO2017听课笔记关键词

听课笔记

Daily dictation 听课笔记

Struts+Hibernate 听课笔记