一 問題
想要在WSL里面安裝yum
執行命令
sudo apt-get install yum
報錯如下
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package yum
報錯信息精華是:E: Unable to locate package yum(E:無法找到包yum)
二 解決方案
1.嘗試了網上提供的解決方案,執行如下代碼,無法解決。
其中apt-get和apt的區別是:在基於 Debian 的 Linux 發行版中,Linux 包管理命令都被分散在了 apt-get、apt-cache 和 apt-config 這三條命令當中。apt 命令的引入就是為了解決命令過於分散的問題,它包括了 apt-get 命令出現以來使用最廣泛的功能選項,以及 apt-cache 和 apt-config 命令中很少用到的功能,在使用 apt 命令時,用戶不必再由 apt-get 轉到 apt-cache 或 apt-config,而且 apt 更加結構化,並為用戶提供了管理軟件包所需的必要選項。
apt update apt-get update apt-get upgrade
2.考慮到報錯信息提示無法找到包yum,嘗試着修改鏡像下載地址
輸入如下命令,查看當前系統信息
lsb_release -c
WSL有個/etc/apt/sources.list,維護着下載軟件的源地址,輸入以下命令進入sources.list文件
sudo edit /etc/apt/sources.list
在首行添加鏡像地址如下
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal universe deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates universe deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security universe deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security multiverse
按esc,輸入:!wq退出后,執行如下命令。對軟件源列表進行更新
apt-get update
更新后,重新執行如下命令,安裝成功
sudo apt-get install yum
三 在WSL下載yum命令后
1.輸入一下命令,本來要檢測是否安裝yum成功。但是WSL終端窗口沒有反應
rpm -qa | grep yum
原因是Ubuntu不支持rpm和yum包管理系統。
對於這個問題,官方說法如下
Do not install rpm in Debian (I don't mean flash-plugin, I mean rpm package management). Debian's package management system (which makes sure everything is installed properly and with no conflicts.) is dpkg and it also includes apt-get, Synaptic and aptitude that use dpkg. RPM will bypass dpkg, so you may cause serious damage to your system.
If you need to install an rpm package, you must do it using the tool "alien". It converts RPM packages to .deb and installs them properly through dpkg.
(不要在Debian中安裝rpm(我不是說閃存插件,我是指rpm軟件包管理)。 Debian的軟件包管理系統(可確保一切安裝正確且沒有沖突。)是dpkg,它還包括使用dpkg的apt-get,Synaptic和aptitude。 RPM將繞過dpkg,因此可能會嚴重損壞系統。 如果需要安裝rpm軟件包,則必須使用工具“ alien”進行安裝。 它將RPM軟件包轉換為.deb並通過dpkg正確安裝。)
2.是用alien將rpm包轉化為deb包。Alien是一個將rpm, dpkg, stampede slp及slackware tgz檔案格式間轉換的工具
首先安裝alien
apt-get install alien
使用alien將rpm包轉換成.deb格式的包
alien package.rpm
執行完成后生成一個.deb的軟件包,再通過dpkg安裝.deb格式的包
dpkg -i package.deb