一,复习
find
-name 按名称搜索,支持通配符
-type d | f
-size K M G+3M,-3M,3M
dd if=/dev/zero of=文件路径 bs=300M count=1
-mtime +3 -3
touch 文件名 -m -d "最后修改时间"
-exec
rm -rf {} \;
find /-size +3M | xargs rm -rf
tree
yum -y install tree ——将文件结构以树状显示
tree -l 2 目录路径
scp ——对文件或目录进行上传和下载
上传 scp /tmp/abc root@192.168.1.22:/opt
上传的是目录:-r
ls -r 递归 目录下的文件(cp)
二,yum源
[root@wanghan ~]# ls -l /etc/yum.repos.d
总用量 4
-rw-r--r--. 1 root root 48 5月 25 17:06 wh.repo
[root@wanghan ~]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
源标识 源名称 状态
!wh da ye 9,911
repolist: 9,911
[root@wanghan ~]# tar -zcvf /etc/yum.repos.d/bak.tar.gz /etc/yum.repos.d/*
tar: 从成员名中删除开头的“/”
/etc/yum.repos.d/bak.tar.gz
/etc/yum.repos.d/wh.repo
[root@wanghan ~]# ls -l /etc/yum.repos.d
总用量 8
-rw-r--r--. 1 root root 652 7月 16 17:56 bak.tar.gz
-rw-r--r--. 1 root root 48 5月 25 17:06 wh.repo
[root@wanghan ~]# rm -rf /etc/yum.repos.d/*.repo
[root@wanghan ~]# ls -l /etc/yum.repos.d
总用量 4
-rw-r--r--. 1 root root 652 7月 16 17:56 bak.tar.gz
将yum源文件/etc/yum.repos.d/打包压缩成文件/bak.tar.gz 保存到/etc/yum.repos.d 中,删除多余的yum源,就可以看到只剩下一个/bak.tar.gz 压缩包了
2、本地yum源:
yum仓库在本地,系统光盘/镜像文件
3、网络yum源:
sliyun 163源 sohu源 清华源 centos源 redhat源 epel源
4、特定软件:
nginx mysql zabbix
5、查看现有的yum仓库镜像
# ls -l /etc/yum.repos.d/
6、显示所有的镜像文件
# yum repolist all
7、打包做成压缩包做备份,并删除所有镜像
# tar -zcvf /etc/yum.repos.d/bak.tar.gz /etc/yum.repos.d/*
# rm -rf /etc/yum.repos.d/*.repo
# ls /etc/yum.repos.d/
bak.tar.gz
# yum makecache
# yum repolist all
repolist: 0 //所有yum都已被删除
8、使用光盘作为yum源仓库
(1)在vmware中装载光盘镜像
(2)把光盘挂载到指定目录下
删除mnt目录下的内容
# rm -rf /mnt/*
# ls /mnt/
lsblk
# lsblk
mount
选项 -o 表示挂载方式
ro=readonly
rw= read and write
# mount -o ro /dev/sr0 /mnt //将光盘挂载到/mnt目录中,就可以载该目录中读取光盘的数据
umount
解除挂载# umount /mnt
# lsblk
sr0 11:0 1 8.8G 0 rom /mnt
9、将挂载添加到开机启动文件中
方法一:
# vim /etc/rc.local
mount -o ro /dev/sr0 /mnt/
方法二:
# echo "mount -o ro /dev/sr0 /mnt/" >> /etc/rc.local
10、编写本地repo文件
1、创建一个repo文件
# vim /etc/yum.repos.d/local.repo
2、编辑内容
# ls /etc/yum.repos.d/
bak.tar.gz local.repo
#yum clean all //清除缓存
# yum makecache //创建缓存
11、验证本地仓库
# yum -y install httpd
12、在linux系统中,给定一个配置文件,如何查询文件中每个选项的作用
#man 5 yum.conf
13、安装网络yum源
1、安装阿里云Centos7
#wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# ls /etc/yum.repos.d/
#yum makecache
# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
# ls /etc/yum.repos.d/
2、安装腾讯云
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
# yum clean all
# yum makecache
# ls /etc/yum.repos.d/
14、EPEl源
对官方和官网源的扩展
# ls /etc/yum.repos.d/CentOS-Base.repo.bak
/etc/yum.repos.d/CentOS-Base.repo.bak
# vim /etc/yum.repos.d/CentOS-Base.repo.bak
# cp /etc/yum.repos.d/CentOS-Base.repo.bak /etc/yum.repos.d/CentOS-Base.repo.d/CentOS-Base.repo
# yum clean all
# yum makecache
使用官方源无法安装:
# yum -y install epel-release
# yum -y install sl
15、nginx
# yum list | grep nginx
# yum -y install nginx.x86_64
# nginx
# curl http://localhost
# nginx //启动nginx
# curl http://localhost
# find / -name "html" -type d
# yum -y remove nginx
# nginx
-bash: /usr/sbin/nginx: 没有那个文件或目录
16、移除epel
# ls /etc/yum.repos.d/
# rm -rf /etc/yum.repos.d/epel*
# ls /etc/yum.repos.d/
# yum clean all
# yum makecache
# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.tecent
# ls /etc/yum.repos.d/
# rm -rf /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/local.repo
# ls /etc/yum.repos.d/
# vim /etc/yum.repos.d/nginx.repo
# yum clean all
# yum makecache
17、创建自建仓库
1、生效阿里云源
# cp /etc/yum.repos.d/CentOS-Base.repo.bak /etc/yum.repos.d/CentOS-Base.repo
# vim /etc/yum.conf
# yum remove tree
# yum install -y tree
# cd /var/cache/yum/
# ls
x86_64
# cd x86_64/
# ls
7
# cd 7/
2、下载samba安装包
# yum install --downloadonly --downloaddir=./soft/ samba //只下载不安装
# ls soft/
3、使用createrepo指令
# yum -y install createrepo 安装
# createrepo soft/
4、在soft目录中发现repodata
# ls soft/
# vim /etc/yum.repos.d/soft.repo
# rm -rf /etc/yum.repos.d/CentOS-Base.repo //删除阿里云源
# ls /etc/yum.repos.d/
# yum clean all
# yum makecache