练习1.插⼊优盘,读取优盘数据
指令:
查看U盘的设备节点 :fdisk -l
然后需要创建一个挂载点:sudo mkdir /mnt/usb
将 U 盘挂载到该挂载点:sudo mount /dev/sdb1 /mnt/usb
练习2.在vmware配置光盘iso⽂件,在linux系统中读取光盘⽂件
指令:
练习3.配置阿⾥云yum仓库
以下是在 CentOS 7 系统上配置阿里云 yum 仓库的步骤:
- 备份原有的 yum 源文件:
mv /etc/yum.repos.d/centos-base.repo /etc/yum.repos.d/centos-base.repo.bak
- 下载阿里云的 yum 源文件:
wget -o /etc/yum.repos.d/centos-base.repo http://mirrors.aliyun.com/repo/centos-7.repo
- 运行以下命令更新 yum 缓存:
yum clean all
yum makecache
5.安装httpd
yum -y install httpd
练习4.配置清华镜像仓库
- 备份原有的 yum 源文件:
mv /etc/yum.repos.d/centos-base.repo /etc/yum.repos.d/centos-base.repo.bak
- 写入配置文件:使用文本编辑器打开新的 yum 源文件
/etc/yum.repos.d/centos-base.repo
,并添加以下内容:
# centos-base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fallback you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=centos-$releasever-base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7
[updates]
name=centos-$releasever-updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7
[extras]
name=centos-$releasever-extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
# mirrorlist=http://mirrorlist.cento
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-7
- 清除并生成缓存:
yum clean all
(清除系统所有的 yum 缓存)
yum makecache
(生成 yum 缓存)
练习5.配置腾讯镜像仓库
下载⽂件
rm -rf /etc/yum.repos.d/CentOS-Base.repo
# cd
# wget -O /etc/yum.repos.d/CentOS-Base.repo
更新缓存
# yum clean all
# yum makecache
练习6.⾃建仓库 包含 tree net-tools bash-completion nginx tree等包
1.安装必要的工具和依赖:
yum install -y createrepo yum-utils
2.创建一个用于存放软件包的目录
mkdir /opt/myrepo
3.将所需的软件包(tree
、net-tools
、bash-completion
、nginx
等)及其依赖包下载到 /opt/myrepo
目录中。
yumdownloader --resolve --destdir=/opt/myrepo tree net-tools bash-completion nginx
4.进入 /opt/myrepo
目录,使用 createrepo
命令创建仓库元数据:
cd /opt/myrepo createrepo.
5.创建 yum 仓库配置文件
[myrepo]
name=My Repository
baseurl=file:///opt/myrepo
enabled=1
gpgcheck=0
上述步骤完成后,就可以使用自建的 yum 仓库来安装软件包了。