第五周(rpm和yum等相关内容)

2018-09-10  本文已影响0人  佐岸的咖啡

1.简述rpm与yum命令的常见选项,并举例

rpm的相关命令和选项

yum命令的常见选项

参数选项 解释说明
repolist [all|enabled|disabled] 显示仓库列表
list [...] 显示程序包
1.yum list [all | glob_exp1] [glob_exp2] [...]
2.yum list {available|installed|updates} [glob_exp1] [...]
install package1 [package2] [...] 安装程序包
reinstall package1 [package2] [...] 重新安装
update [package1] [package2] [...] 升级程序包
downgrade package1 [package2] [...] 降级程序包
check-update 检查可用升级
remove | erase package1 [package2] [...] 卸载程序包
info [...] 查看程序包information
provides | whatprovides feature1 [feature2] [...] 查看指定的特性是由哪个程序包所提供
clean [ packages | metadata | expire-cache | rpmdb | plugins | all ] 清理本地缓存
makecache [fast] 构建缓存
search string1 [string2] [...] 以指定关键字搜索程序包名及summary信息
deplist package1 [package2] [...] 查看指定包所依赖的capabilities
history [info|list|stats] 查看yum事务历史
group 包组管理的相关命令
1.groupinstall group1 [group2] [...]
2.groupupdate group1 [group2] [...]
3.grouplist [hidden] [groupwildcard] [...]
4.groupremove group1 [group2] [...]
5.groupinfo group1 [...]
6.search string1 [string2] [...]

2、自建yum仓库,分别为网络源和本地源

第一、如何自建本地yum源仓库
[root@Centos7 ~]#yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: centos.ustc.edu.cn
 * updates: centos.ustc.edu.cn
repo id                                     repo name                                      status
base/7/x86_64                               CentOS-7 - Base                                9,911
extras/7/x86_64                             CentOS-7 - Extras                                402
updates/7/x86_64                            CentOS-7 - Updates                             1,333
repolist: 11,646
[root@Centos7 yum.repos.d]#mkdir backup
[root@Centos7 yum.repos.d]#ll
total 36
drwxr-xr-x. 2 root root 4096 Sep 11 01:21 backup
-rw-r--r--. 1 root root 1664 Apr 29 00:35 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Apr 29 00:35 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Apr 29 00:35 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Apr 29 00:35 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Apr 29 00:35 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Apr 29 00:35 CentOS-Sources.repo
-rw-r--r--. 1 root root 4768 Apr 29 00:35 CentOS-Vault.repo
[root@cherry yum.repos.d]# mv CentOS-* backup
[root@Centos7 ~]#mkdir /mnt/cdrom
[root@Centos7 ~]#mount -r /dev/cdrom /mnt/cdrom
[root@Centos7 ~]#cd /etc/yum.repos.d/
[root@Centos7 yum.repos.d]#ll
total 4
drwxr-xr-x. 2 root root 4096 Sep 11 01:22 backup
[root@Centos7 yum.repos.d]#vim /etc/yum.repos.d/CentOS_local.repo
[local]
name=CentOS7 local_source
baseurl=file:///mnt/cdrom
gbgcheck=0
enabled=1

[root@Centos7 ~]#yum clean all
[root@cherry yum.repos.d]# yum makecache
[root@cherry yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id                                repo name                                           status
local                                  CentOS7 local_source                                9,911
repolist: 9,911ed

第二、如何自建网络yum源

第一种方案,直接修改repo源,和上述本地方案类似,最后一步配置页面做一下更改;

[root@Centos7 yum.repos.d]#vim /etc/yum.repos.d/CentOS_local.repo
[network]
name=CentOS7 network_source
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gbgcheck=0
enabled=1

第二种方案通过安装http或ftp服务构建;

[root@cherry ~]# yum install httpd
[root@cherry yum.repos.d]# systemctl start httpd
[root@cherry ~]# cd /var/www/html
[root@cherry html]# mkdir -pv httpd/1/2
[root@cherry html]# mount -r /dev/cdrom /var/www/html/httpd/1

3、简述at和crontab命令,制定一个脚本每周三的凌晨三、五点10分执行某个脚本,输出当前时间,时间格式为 2017-12-28 10:00:00

at [OPTION]...TIME

crontab命令:

10 3,5 0 0 3 /usr/bin/echo "The present time is $(date "+%F %H:%m:%S")."

4、简述sed常用操作命令,并举例

上一篇下一篇

猜你喜欢

热点阅读