尝试这样做sudo apt-get update
,每次运行时都会得到此响应:
Get:1 http://repo.radeon.com/rocm/apt/debian xenial InRelease [1814 B]
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Err:1 http://repo.radeon.com/rocm/apt/debian xenial InRelease
Couldn't create temporary file /tmp/apt.conf.RpjjUo for passing config to apt-key
Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
Couldn't create temporary file /tmp/apt.conf.IvhgJr for passing config to apt-key
Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Err:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Couldn't create temporary file /tmp/apt.conf.F98B6M for passing config to apt-key
Get:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Err:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Couldn't create temporary file /tmp/apt.conf.WWtE1d for passing config to apt-key
Get:3 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
Err:3 http://archive.ubuntu.com/ubuntu bionic InRelease
Couldn't create temporary file /tmp/apt.conf.TP8dgO for passing config to apt-key
Reading package lists... Done
W: GPG error: http://repo.radeon.com/rocm/apt/debian xenial InRelease: Couldn't create temporary file /tmp/apt.conf.RpjjUo for passing config to apt-key
E: The repository 'http://repo.radeon.com/rocm/apt/debian xenial InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://security.ubuntu.com/ubuntu bionic-security InRelease: Couldn't create temporary file /tmp/apt.conf.IvhgJr for passing config to apt-key
E: The repository 'http://security.ubuntu.com/ubuntu bionic-security InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://archive.ubuntu.com/ubuntu bionic-updates InRelease: Couldn't create temporary file /tmp/apt.conf.F98B6M for passing config to apt-key
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://archive.ubuntu.com/ubuntu bionic-backports InRelease: Couldn't create temporary file /tmp/apt.conf.WWtE1d for passing config to apt-key
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://archive.ubuntu.com/ubuntu bionic InRelease: Couldn't create temporary file /tmp/apt.conf.TP8dgO for passing config to apt-key
E: The repository 'http://archive.ubuntu.com/ubuntu bionic InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
试过了sudo apt-get clean
,什么都没发生。sudo apt-get upgrade
表明没有什么需要升级。sudo apt-get check
也没有发现任何东西。
在 Windows 10 上使用 Ubuntu。
答案1
您可能更改了文件夹的文件权限/tmp
,请检查
ls -lad /tmp
的正常设置为/tmp
1777,ls
显示为drwxrwxrwt
。也就是说:完全开放,但只有文件的所有者才能删除它(这就是这个额外的t
位对于目录的意义)。
如果设置错误,可以使用以下方法恢复:
chmod 1777 /tmp
我建议在进行此更改后重新启动机器。
如果无法重新启动,请检查此处的答案:https://unix.stackexchange.com/a/71625/20661
另一种可能性是某些东西被挂载到 /tmp。使用以下命令检查
mount | grep /tmp
注意:也用/var/tmp
同样的方式检查,也许你会遇到同样的错误
答案2
对我来说,我使用的是 Docker 容器,并/tmp
在容器中挂载了一个目录,这导致了冲突。我删除了挂载的目录,/tmp
这样就可以正常apt update
工作了。
答案3
我在 docker 中看到了这个问题。我不得不删除一些 docker 镜像并重建它们。这是在我更改 docker 的根目录后发生的。
答案4
就我而言,问题在于我的磁盘有错误。
ls -lad /tmp
很好,显示drwxrwxrwt
,正如这个答案所解释的那样。
所以,事实证明我必须fsck
在根目录上运行。
首先运行df -h
以查看您有哪些磁盘。找到挂载为您的根磁盘位于挂载点/
。我的是/dev/mapper/sda4_crypt
。因此,我必须运行以下命令:
fsck /dev/mapper/sda4_crypt -y
...正如这个答案所解释的那样。
我之所以能解决这个问题,是因为我重启了系统,想看看这是否能解决我的sudo apt update
错误问题,但我的系统无法启动。它启动initramfs
后进入了菜单,正如我上面链接的问答中解释的那样。
然后按照这些指示并从initramfs
菜单重新启动,如下所示:
fsck /dev/mapper/sda4_crypt -y
reboot
exit
...然后重新登录后,sudo apt update
又可以工作了!
以前,它显示各种类型Couldn't create temporary file /tmp/apt.conf.RpjjUo for passing config to apt-key
错误,如本问题所示。
一旦sudo apt update
再次工作,我必须这样做,因为引用我的回答:
sudo apt update sudo apt full-upgrade # ...which told me to run `sudo apt --fix-broken install`, so I did that: sudo apt --fix-broken install
然后,重新运行软件更新程序 GUI 工具。