红帽 redhat 更改yum源为本地光盘(cdrom)
16lz
2021-01-22
学习Linux安装tree命令,发现红帽默认无法使用yum。查询资料了解到修改yum源的方法如下:
- 在/mnt目录下增加一个cdrom目录进行挂载;
- 编辑/etc/yum.repos.d 下的repo文件。
- 具体步骤如下:
- 默认安装yum报错,如下
[root@localhost ~]# yum install treeLoaded plugins: langpacks, product-id, search-disabled-repos, subscription-managerThis system is not registered with an entitlement server. You can use subscription-manager to register.There are no enabled repos. Run "yum repolist all" to see the repos you have. To enable Red Hat Subscription Management repositories: subscription-manager repos --enable <repo> To enable custom repositories: yum-config-manager --enable <repo>
- 创建一个挂载点。
[root@localhost ~]# mkdir /mnt/cdrom[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/[root@localhost ~]# ll /mnt/cdrom/total 962dr-xr-xr-x. 4 root root 2048 Oct 10 2018 addonsdr-xr-xr-x. 3 root root 2048 Oct 10 2018 EFI-r--r--r--. 1 root root 8266 Apr 4 2014 EULA-r--r--r--. 1 root root 1455 Oct 10 2018 extra_files.json-r--r--r--. 1 root root 18092 Mar 6 2012 GPLdr-xr-xr-x. 3 root root 2048 Oct 10 2018 imagesdr-xr-xr-x. 2 root root 2048 Oct 10 2018 isolinuxdr-xr-xr-x. 2 root root 2048 Oct 10 2018 LiveOS-r--r--r--. 1 root root 114 Oct 10 2018 media.repodr-xr-xr-x. 2 root root 931840 Oct 10 2018 Packagesdr-xr-xr-x. 2 root root 4096 Oct 10 2018 repodata-r--r--r--. 1 root root 3375 Sep 21 2018 RPM-GPG-KEY-redhat-beta-r--r--r--. 1 root root 3211 Sep 21 2018 RPM-GPG-KEY-redhat-release-r--r--r--. 1 root root 1796 Oct 10 2018 TRANS.TBL
3.进入repos目录,创建repo文件,增加cdrom源,“RPM-GPG-KEY-redhat-release”该名称从cdrom目录中查找。
[root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# ls redhat.repo [root@localhost yum.repos.d]# mv redhat.repo redhat.repo.bak [root@localhost yum.repos.d]# vi iso.repo [root@localhost yum.repos.d]# cat iso.repo [base] name=centos baseurl=file:///mnt/cdrom enable=1 gpgcheck=0 gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release
4.清理yum:yum clean all
5.安装tree命令
[root@localhost yum.repos.d]# yum -y install treeLoaded plugins: langpacks, product-id, search-disabled-repos, subscription-managerThis system is not registered with an entitlement server. You can use subscription-manager to register.base | 4.3 kB 00:00:00(1/2): base/group_gz | 146 kB 00:00:00(2/2): base/primary_db | 4.2 MB 00:00:00Resolving Dependencies--> Running transaction check---> Package tree.x86_64 0:1.6.0-10.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved========================================================================================= Package Arch Version Repository Size=========================================================================================Installing: tree x86_64 1.6.0-10.el7 base 46 kTransaction Summary=========================================================================================Install 1 PackageTotal download size: 46 kInstalled size: 87 kDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : tree-1.6.0-10.el7.x86_64 1/1base/productid | 1.6 kB 00:00:00 Verifying : tree-1.6.0-10.el7.x86_64 1/1Installed: tree.x86_64 0:1.6.0-10.el7Complete!
6.至此修改yum源为本地完成。
©著作权归作者所有:来自51CTO博客作者ThinkingFrog的原创作品,如需转载,请注明出处,否则将追究法律责任更多相关文章
- 如何使用Python执行系统命令?Python学习教程!
- linux文件目录结构汇总!Linux学习
- rsync和sersync实时同步文件
- 6、用户身份与文件权限
- 7、文件系统与磁盘划分
- spring boot 上传文件到指定目录
- 创建第一个".py" 和 ".ipynb" 文件
- Python办公自动化|批量处理文件,一学就会
- JDBC自定义工具类(properties配置文件方式)