0

有什么办法可以分解这行代码?它总是返回权限错误。我正在 Google Cloud 上部署 fusionPBX。

sudo wget -O - https://raw.githubusercontent.com/fusionpbx/fusionpbx-install.sh/master/ubuntu/pre-install.sh | sh;
sudo cd /usr/src/fusionpbx-install.sh/ubuntu && ./install.sh

我收到了这个错误

E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
fatal: could not create work tree dir 'fusionpbx-install.sh': Permission denied
sh: 13: cd: can't cd to /usr/src/fusionpbx-install.sh/ubuntu
4

1 回答 1

1

看看你的命令:

$ sudo cd /usr/src/fusionpbx-install.sh/ubuntu && ./install.sh

只有左侧(第一个)命令将以 root 权限运行:

sudo cd /usr/src/fusionpbx-install.sh/ubuntu

但是右侧(第二个)命令之后&&将以用户权限运行(&&意味着右侧(第二个)命令仅在左侧(第一个)命令成功时才会运行):

./install.sh

您可以在错误消息中看到它:

E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)

甚至更清楚:

E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

要使此问题更加明显,您可以运行以下命令:

$ sudo whoami && whoami
root
username

要解决此问题,您应该更改命令:

$ sudo whoami && sudo whoami     
root
root

如果您有一些需要执行的命令,可以通过以下方式执行:

$ sudo -s
# whoami && whoami 
root
root
# whoami && whoami 
root
root
exit
$

此外,我检查了FusionPBX 文档并在我的测试 VM 上尝试了 Debian 的步骤:

Debian

Debian 9 是 FreeSWITCH 开发人员的首选操作系统。它支持最新的视频依赖,如果你想做视频混合,应该使用它。在https://cdimage.debian.org/cdimage/release/current/下载 Debian 9 Stretch

wget -O - https://raw.githubusercontent.com/fusionpbx/fusionpbx-install.sh/master/debian/pre-install.sh | sh;
cd /usr/src/fusionpbx-install.sh/debian && ./install.sh

但与你的相比,我改变了它们:

wget -O - https://raw.githubusercontent.com/fusionpbx/fusionpbx-install.sh/master/ubuntu/pre-install.sh | sudo sh;
cd /usr/src/fusionpbx-install.sh/debian && sudo ./install.sh

并没有发现任何问题。

于 2020-05-06T08:37:05.837 回答