sudo apt-get update 无法创建临时文件

sudo apt-get update 无法创建临时文件

尝试这样做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

的正常设置为/tmp1777,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 工具。

也可以看看

  1. 我在这里发表评论,并回顾了这个答案:https://askubuntu.com/questions/137655/boot-drops-to-a-initramfs-prompts-busybox/817660#comment2520181_817660

相关内容