我无法更新和升级软件。它显示一些错误

我无法更新和升级软件。它显示一些错误
aditya@aditya-pc:~$ sudo apt-get update
Reading package lists... Done
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
W: Target Packages (partner/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:45 and /etc/apt/sources.list.d/xenial-partner.list:4
W: Target Packages (partner/binary-i386/Packages) is configured multiple times in /etc/apt/sources.list:45 and /etc/apt/sources.list.d/xenial-partner.list:4
W: Target Packages (partner/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:45 and /etc/apt/sources.list.d/xenial-partner.list:4
W: Target Translations (partner/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list:45 and /etc/apt/sources.list.d/xenial-partner.list:4
W: Target Translations (partner/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:45 and /etc/apt/sources.list.d/xenial-partner.list:4
W: Target Translations (partner/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:45 and /etc/apt/sources.list.d/xenial-partner.list:4
W: Target DEP-11 (partner/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:45 and /etc/apt/sources.list.d/xenial-partner.list:4
W: Target DEP-11-icons (partner/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:45 and /etc/apt/sources.list.d/xenial-partner.list:4

答案1

首先使用以下命令修复多行错误:

sudo rm /etc/apt/sources.list.d/xenial-partner.list*

或者如果上述命令在末尾没有星号而引发错误:

sudo rm /etc/apt/sources.list.d/xenial-partner.list

然后,要么重启电脑,要么简单地等一会儿,如果你刚刚启动了它,可能是你激活了无人值守更新,并且此过程正在锁定管理目录。如果这仍然不起作用,你可以使用以下命令(注意,仅当情况在等待片刻后仍未自行修复时才使用此命令,如@RoVo评论):

sudo rm -vf /var/lib/apt/lists/*

选项-v用于显示详细输出,选项-f用于强制执行命令,这里将它们合并为一个。请记住在从计算机中删除实际列表后-vf重新运行。sudo apt update

为了修复 CD-Rom 错误,您需要编辑文件中的第一行/多行,并在提到 cdrom 的行前面/etc/apt/sources.list添加:#

deb cdrom://Ubuntu 16.04.1 LTS Xenial Xerus - Release amd64 (20160719) xenial 
deb-src cdrom://Ubuntu 16.04.1 LTS Xenial Xerus - Release amd64 (20160719) xenial

进入

# deb cdrom://Ubuntu 16.04.1 LTS Xenial Xerus - Release amd64 (20160719) xenial 
# deb-src cdrom://Ubuntu 16.04.1 LTS Xenial Xerus - Release amd64 (20160719) xenial

相关内容