使用 sudo 运行时,如何克服权限被拒绝错误?

使用 sudo 运行时,如何克服权限被拒绝错误?

我正在使用以下版本的 Linux……

[davea@mydevbox ~]$ uname -a
Linux mydevbox.evo-text.com 4.4.5-15.26.amzn1.x86_64 #1 SMP Wed Mar 16 17:15:34 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

我正在尝试安装 node.js,但即使我使用 sudo 运行,也收到以下权限被拒绝错误。我还需要做什么才能成功运行此命令?以下是发生的情况

[davea@mydevbox ~]$ sudo curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -

## Installing the NodeSource Node.js 4.x LTS Argon repo...


## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el7-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_4.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.PfqaTA4YLm' 'https://rpm.nodesource.com/pub_4.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.PfqaTA4YLm'
error: cannot open Packages index using db4 - Permission denied (13)
error: cannot open Packages database in /var/lib/rpm
Error executing command, exiting

答案1

curl --silent --locationhttps://rpm.nodesource.com/setup_4.x| sudo bash -

基本上,需要以 sudo 身份运行的是 bash 命令,而不是 curl

相关内容