注意:Ubuntu系统默认使用APT包管理器(对应仓库文件位于/etc/apt/sources.list或/etc/apt/sources.list.d/目录),而YUM是Red Hat系列(如CentOS、Fedora)的包管理器。若Ubuntu系统误装了YUM,需先明确需求:
若Ubuntu系统中存在YUM仓库配置(例如手动添加的.repo文件),可按以下步骤移除:
Ctrl+Alt+T进入终端。/etc/yum.repos.d/目录(以.repo为扩展名)。
.repo文件:ls /etc/yum.repos.d/
example.repo)。.repo文件:sudo rm /etc/yum.repos.d/example.repo
(将example.repo替换为实际文件名)sudo yum clean all
若需移除Ubuntu默认的APT仓库(而非YUM),步骤如下:
/etc/apt/sources.list.d/目录(以.list为扩展名)。
.list文件:ls /etc/apt/sources.list.d/
.list文件(例如ppa-example.list):sudo rm /etc/apt/sources.list.d/ppa-example.list
/etc/apt/sources.list中的默认仓库,可使用文本编辑器(如nano)注释相关条目(行首添加#):sudo nano /etc/apt/sources.list
修改后保存(Ctrl+O→Enter→Ctrl+X)。sudo apt update
sudo apt remove yum yum-utils python-yum
/etc/apt/sources.list.d/下的文件)。以上步骤覆盖了Ubuntu系统中移除YUM仓库或APT仓库的常见场景,可根据实际需求选择对应操作。