两个命令之间的区别

两个命令之间的区别

有什么区别

1:sudo add-apt-repository ppa:ppaname

2:sudo -E add-apt-repository ppa:ppaname

当我使用 ubuntu 14.04 时,我必须使用,sudo -E add-apt-repository ppa:ppaname但现在 ubuntu 16.04 不需要该-E选项。

我在 ubuntu 14.04 上遇到的错误:

sudo add-apt-repository ppa:linrunner/tlp
Cannot add PPA: 'ppa:linrunner/tlp'
Please check that the PPA name or format is correct.

答案1

sudo手册页中:

 -E          The -E (preserve environment) option indicates to the security policy that the user wishes to preserve their existing environment variables.  The security policy may return an error if the -E
             option is specified and the user does not have permission to preserve the environment.

在不知道您在 14.04 中未包含 -E 选项时遇到了什么错误的情况下,我不确定如何回答您的真正问题...但它可能与您为本地用户已有的环境变量有关,而在 16.04 中,这些相同的变量要么不需要,要么已经存在于根用户中。

答案2

来自 sudo 手册页:
-E, --preserve-env Indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the user does not have permission to preserve the environment.
因此,当以 root 身份运行时,它会保留您的用户环境。我不确定这对 add-apt-repository 有什么影响... 使用 14.04(或任何 Ubuntu 版本)时,我不需要 -E 选项。

相关内容