一、RPM包管理介绍
RPM是radhat系列和suse系列等的包管理系统,主要管理系统上软件包的安装、卸载和查询
rpm安装语法:rpm [install options] [programname…]
常用安装option:-i,表示安装程序包
-v,表示输出详细安装过程
-h,安装过程输出进度条
-U,升级程序包
-c,查看程序包的配置文件路劲
--force,忽略程序包的冲突关系
--nodeps,忽略程序包的依赖关系强制安装
-e,卸载程序包
常用安装升级组合:
1、安装程序包
rpm -ivh [程序包路劲] 用来安装程序包并显示安装信息进度
2、升级程序包
rpm -Uvh [程序包路劲] 用来升级程序包并显示安装信息进度
3、rpm -e [程序包名称] 用来卸载程序包
rpm查询语法: rpm [query ostions] [程序包名|程序文件]
常用查询option:-q,表示查询信息,执行查询必带的参数
-a,查询所有已安装的程序包
-f,查询程序包产生的文件
-l,查询指包名的程序文件
-d,查询程序包的安装文档
-i,查询程序包的相关信息
-R,查询程序包的依赖关系
常用组合示例:
1、查询指定程序包的相关信息
[root@suyiwen01 ~]# rpm -qi httpd
Name : httpd
Version : 2.4.6
Release : 67.el7.centos.6
Architecture: x86_64
Install Date: Wed 28 Mar 2018 11:37:25 AM CST
Group : System Environment/Daemons
Size : 9827789
License : ASL 2.0
Signature : RSA/SHA256, Fri 20 Oct 2017 08:31:20 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : httpd-2.4.6-67.el7.centos.6.src.rpm
Build Date : Fri 20 Oct 2017 04:41:19 AM CST
Build Host : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://httpd.apache.org/
Summary : Apache HTTP Server
Description :
The Apache HTTP Server is a powerful, efficient, and extensible
web server.
2、查询程序包产生的文件
[root@suyiwen01 ~]# rpm -ql httpd
/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
/etc/httpd/conf.d/README
......
3、查询程序包的依赖关系
[root@suyiwen01 ~]# rpm -qR mariadb
/bin/sh
/usr/bin/perl
/usr/sbin/update-alternatives
/usr/sbin/update-alternatives
bash
config(mariadb) = 1:5.5.56-2.el7
fileutils
.....
4、查询指定文件由哪个程序产生
[root@suyiwen01 ~]# rpm -qf /etc/hostname
systemd-219-42.el7.x86_64
[root@suyiwen01 ~]#
二、CentOS系统yum详解
yum是基于rpm的包管理系统,可以自动为程序包解决依赖关系,简化对软件包的安装、升级、查询和卸载
语法格式 yum [options] [program name] [subcommand] [程序包]
常用option:
-y,对所有回答为yes
-q,静默模式
常用子命令
install,安装程序包
remove,卸载chengxubao
update,升级程序包
list,查看程序包列表
seach,搜索程序包
info,查看软件包信息
check-update,查看可以升级的程序包
clean,清除yum repo缓存
groupinstall,安装程序包组
grouplist,查看程序包组列表
localinstall,安装本地程序包
deplist,显示软件包的依赖关系
常用示例:
1、安装指定软件包
[root@suyiwen01 ~]# yum install ntp -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.6p5-25.el7.centos.2 will be installed
--> Processing Dependency: ntpdate = 4.2.6p5-25.el7.centos.2 for package: ntp-4.2.6p5-25.el7.centos.2.x86_64
--> Processing Dependency: libopts.so.25()(64bit) for package: ntp-4.2.6p5-25.el7.centos.2.x86_64
.....
2、查看指定软件包的信息
[root@suyiwen01 ~]# yum info ntp
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Available Packages
Name : ntp
Arch : x86_64
Version : 4.2.6p5
Release : 25.el7.centos.2
Size : 547 k
Repo : base/7/x86_64
Summary : The NTP daemon and utilities
URL : http://www.ntp.org
License : (MIT and BSD and BSD with advertising) and GPLv2
Description : The Network Time Protocol (NTP) is used to synchronize a computer's
: time with another reference time source. This package includes ntpd
: (a daemon which continuously adjusts system time) and utilities used
: to query and configure the ntpd daemon.
:
: Perl scripts ntp-wait and ntptrace are in the ntp-perl package,
: ntpdate is in the ntpdate package and sntp is in the sntp package.
: The documentation is in the ntp-doc package.
3、安装指定包组
[root@suyiwen01 ~]# yum groupinstall "Development Tools"
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
.....
4、卸载指定程序包
[root@suyiwen01 ~]# yum remove ntp -y
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package ntp.x86_64 0:4.2.6p5-25.el7.centos.2 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
......
5、升级指定程序包
[root@suyiwen01 ~]# yum update systemd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
......
yum源配置
配置yum配置文件
[base] //yum源仓库名
name= //yum源名字信息
baseurl= //yum源路径
enable= //是否启用源
gpgcheck= //是否启用key检查
gpgkey= //key路径
三、文本处理三剑客之sed常基础用法
sed是一个流式的文本处理工具
语法:sed [OPTION]… {script-only-if-no-other-script} [input-file]…
常用option:
-n,静默模式,不输出内容至屏幕,经过sed特殊处理的那一行才会显示出来
-e script,根据script进行编辑
-r,使用扩展正则表达式匹配
-f,后跟script命令文件进行编辑
-i,直接编辑原文件
常用script命令:
a,新增一行内容
c,替换匹配到的字符串为指定字符串
d,删除匹配到的字符串
s,查找替换
i,在当前行前前插入一行内容
示例1:显示/etc/fstab的第5到第10行
[root@suyiwen01 ~]# sed -n "5,10p" /etc/fstab
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=add4bda5-b5b9-44c4-91ad-d0f55e313ae8 /boot xfs defaults 0 0
示例2:删除/boot/grub/grub2.cfg文件中所有以空白字符开头的行的行首的所有空白字符
[root@localhost ~]# sed -e "s@^#[[:space:]]*@@" /etc/fstab
/etc/fstab
Created by anaconda on Mon Mar 26 17:26:06 2018
Accessible filesystems, by reference, are maintained under '/dev/disk'
See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
/dev/mapper/centos-root / xfs defaults 0 0
UUID=83a1568a-0c24-4e08-bf70-f15cc8489bde /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
示例3:将/etc/inittab中的#号,替换为//
[root@localhost ~]# sed "s@#@//@" /etc/inittab
// inittab is no longer used when using systemd.
//
// ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
//
// Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
//
// systemd uses 'targets' instead of runlevels. By default, there are two main targets:
//
// multi-user.target: analogous to runlevel 3
// graphical.target: analogous to runlevel 5
//
// To view current default target, run:
......
本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/94591
评论列表(1条)
笔记写的不错。