學習Linux安裝tree命令,發現紅帽默認無法使用yum。查詢資料瞭解到修改yum源的方法如下:
- 在/mnt目錄下增加一個cdrom目錄進行掛載;
- 編輯/etc/yum.repos.d 下的repo文件。
- 具體步驟如下:
- 默認安裝yum報錯,如下
[root@localhost ~]# yum install tree
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This 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 962 dr-xr-xr-x. 4 root root 2048 Oct 10 2018 addons dr-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 GPL dr-xr-xr-x. 3 root root 2048 Oct 10 2018 images dr-xr-xr-x. 2 root root 2048 Oct 10 2018 isolinux dr-xr-xr-x. 2 root root 2048 Oct 10 2018 LiveOS -r--r--r--. 1 root root 114 Oct 10 2018 media.repo dr-xr-xr-x. 2 root root 931840 Oct 10 2018 Packages dr-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 tree
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This 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:00
Resolving Dependencies
--> Running transaction check
---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================
Package Arch Version Repository Size
=========================================================================================
Installing:
tree x86_64 1.6.0-10.el7 base 46 k
Transaction Summary
=========================================================================================
Install 1 Package
Total download size: 46 k
Installed size: 87 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : tree-1.6.0-10.el7.x86_64 1/1
base/productid | 1.6 kB 00:00:00
Verifying : tree-1.6.0-10.el7.x86_64 1/1
Installed:
tree.x86_64 0:1.6.0-10.el7
Complete!
6.至此修改yum源爲本地完成。