文档: https://docs.stardog.com/install-stardog/linux-installation
$ curl http://packages.stardog.com/stardog.gpg.pub | apt-key add
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
E: This command can only be used by root.
100 1760 100 1760 0 0 581 0 0:00:03 0:00:03 --:--:-- 581
curl: (23) Failed writing body
aliza@ingestrom:~$ sudo curl http://packages.stardog.com/stardog.gpg.pub | apt-key add
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
E: This command can only be used by root.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1760 100 1760 0 0 1212 0 0:00:01 0:00:01 --:--:-- 1212
curl: (23) Failed writing body
答案1
aliza@ingestrom:~$ sudo curl http://packages.stardog.com/stardog.gpg.pub | apt-key add
它curl
以 root 身份运行。但curl
仅连接到网站(http://packages.stardog.com/stardog.gpg.pub),并将该 URL 的内容输出到标准输出 (stdout)。这不需要任何特殊权限。
但是,管道是一个分隔符 - 您正在运行两个命令,而不是一个。首先执行 curl,然后 curl 的 stdout 被传送到 apt-key 的 stdin(标准输入)。后一个命令需要 root 权限。
抱怨必须以 root 身份运行的命令(E: This command can only be used by root.
)是apt-key
。
将您的命令更改为
curl http://packages.stardog.com/stardog.gpg.pub | sudo apt-key add