无法使用 snap return 安装 certbot:如果存在,运行“certbot”snap 的配置钩子

无法使用 snap return 安装 certbot:如果存在,运行“certbot”snap 的配置钩子

我想使用 snap 安装 certbot,但是当我尝试官方说明

sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot

但返回:

错误:无法执行以下任务:

  • 如果存在,则运行“certbot”快照的配置钩子(运行钩子“配置”:/var/lib 非 root 拥有的 1000:1000)

之前,我使用以下命令卸载了 certbot(来自 apt):

sudo apt-get remove -y certbot python3-certbot-apache

发生了什么?我正在使用 Ubuntu 18.04 Bionic

从错误来看,我需要将所有者更改/var/lib为 root 用户。但我更改后仍然出现相同的错误。我应该递归地将文件夹更改为 root 吗?

以下ls/var/lib

drwxr-xr-x  4 myuser       myuser       4.0K Mar 10  2020 AccountsService
drwxr-xr-x  5 myuser       myuser       4.0K Mar 24  2020 apache2
drwxr-xr-x  5 myuser       myuser       4.0K Oct  4 02:36 apt
drwxr-xr-x  2 root      root      4.0K Sep  8 02:03 binfmts
drwxr-xr-x  2 myuser       myuser       4.0K May  5  2018 command-not-found
drwxr-xr-x  2 myuser       myuser       4.0K Mar 10  2020 dbus
drwxr-xr-x  2 myuser       myuser       4.0K Apr 16  2018 dhcp
drwxr-xr-x  3 myuser       myuser       4.0K Mar 10  2020 dictionaries-common
drwxr-xr-x  7 myuser       myuser       4.0K Oct  4 02:36 dpkg
drwxr-xr-x  2 myuser       myuser       4.0K Dec  9  2019 git
drwxr-xr-x  3 myuser       myuser       4.0K Mar 10  2020 grub
drwxr-xr-x  2 myuser       myuser       4.0K Oct  3 14:52 initramfs-tools
drwxr-xr-x  2 landscape landscape 4.0K Mar 10  2020 landscape
drwxr-xr-x  4 myuser       myuser       4.0K Oct  4 02:34 letsencrypt
drwxr-xr-x  3 myuser       myuser       4.0K Mar 10  2020 locales
drwxr-xr-x  2 myuser       myuser       4.0K Oct  3 06:25 logrotate
drwxr-xr-x  2 root      root         0 Oct  4 02:56 lxcfs
drwxr-xr-x  2 lxd       nogroup   4.0K Jun 16 00:42 lxd
drwxr-xr-x  2 myuser       myuser       4.0K Mar 10  2020 man-db
drwxr-xr-x  2 myuser       myuser       4.0K Apr 24  2018 misc
drwxr-xr-x  2 myuser       myuser       4.0K Oct  3 06:25 mlocate
drwx------ 35 mysql     mysql     4.0K Oct  3 14:51 mysql
drwx------  2 mysql     mysql     4.0K Mar 24  2020 mysql-files
drwx------  2 mysql     mysql     4.0K Mar 24  2020 mysql-keyring
drwxr-xr-x  2 root      root      4.0K Jan 21  2020 mysql-upgrade
drwxr-xr-x  2 myuser       myuser       4.0K Oct  3 14:50 pam
drwxr-xr-x  4 myuser       myuser       4.0K Mar 24  2020 php
drwxr-xr-x  2 myuser       myuser       4.0K Apr  4  2019 plymouth
drwx------  3 myuser       myuser       4.0K Mar 10  2020 polkit-1
drwxr-xr-x  6 postgres  postgres  4.0K Oct  3 14:50 postgresql
drwx------  3 myuser       myuser       4.0K Mar 10  2020 private
drwxr-xr-x  2 myuser       myuser       4.0K Mar 24  2020 python
drwxr-x---  2 redis     redis     4.0K Feb 24  2021 redis
drwxr-xr-x 21 myuser       myuser       4.0K Oct  4 02:46 snapd
drwxr-xr-x  3 myuser       myuser       4.0K Mar 10  2020 sudo
drwxr-xr-x  7 root      root      4.0K Oct  4 02:36 systemd
drwxr-xr-x  3 root      root      4.0K Jun 27 13:26 ubuntu-advantage
drwxr-xr-x  2 myuser       myuser       4.0K Oct  3 14:53 ubuntu-release-upgrader
drwxr-xr-x  3 myuser       myuser       4.0K Oct  3 14:52 ucf
drwxr-xr-x  2 myuser       myuser       4.0K Nov 25  2019 unattended-upgrades
drwxr-xr-x  2 myuser       myuser       4.0K Mar 10  2020 update-manager
drwxr-xr-x  4 myuser       myuser       4.0K Oct  4 02:44 update-notifier
drwxr-xr-x  3 myuser       myuser       4.0K Mar 10  2020 ureadahead
drwxr-xr-x  2 myuser       myuser       4.0K Mar 10  2020 usbutils
drwxr-xr-x  3 myuser       myuser       4.0K Mar 10  2020 vim

答案1

我只需要/var/lib/snapd使用以下命令将文件夹更改为 root 用户:

chown root:root -R /var/lib/snapd/

在其他服务器上,/var/lib文件夹和里面的内容都是 root 拥有的。我不清楚为什么这台服务器上的文件夹用户不是 root,更改后我现在可以安装 certbot 并使用它。

相关内容