如何以 root 身份运行 sudo 命令?

发布于 2024-09-13 16:14:12 字数 236 浏览 5 评论 0原文

我只有服务器的根访问权限,因此 sudo 命令不起作用。我正在尝试运行一个尝试使用 sudo 命令的命令,但由于我已经具有 root 访问权限,所以它失败了。

未找到命令:sudo chmod +x /usr/local/bin/wkhtmltopdf

有没有办法让我运行此命令?我可以以某种方式退出 root 权限,或者让 root 暂时能够使用 sudo 命令吗?

I only have root access to my server and the sudo command therefore does not work. I am trying to run a command that tries to use the sudo command and as I already have root access, it fails.

command not found: sudo chmod +x /usr/local/bin/wkhtmltopdf

Is there a way that I can get this command to run? Can I move out of root somehow, or make root temporarily able to use the sudo command?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

人疚 2024-09-20 16:14:13

刚刚尝试过,它对我有用
(在 Mandriva Linux 上;其他发行版应该没有什么不同)。

您真的安装了 sudo 吗?
某些发行版上并非默认设置。

Just tried it and it worked for me
(on Mandriva Linux; other distros shouldn't be different).

Do you really have sudo installed?
It is not by default on some distros.

池木 2024-09-20 16:14:13

如果您以 root 身份登录,您不能在没有 sudo 的情况下运行命令吗?

IE

chmod +x /usr/local/bin/wkhtmltopdf

If you are logged in as root can't you just run your command without the sudo?

ie

chmod +x /usr/local/bin/wkhtmltopdf
黯然#的苍凉 2024-09-20 16:14:13

正如其他人提到的,如果您已经是 root,通常不需要使用 sudo。但是,如果您编写一些脚本或类似的内容,并且需要在使用 root 用户而不是 root 用户时运行它,则需要将完整部分放入 sudo 命令中。
您可以找到从非 root 用户运行 whereis sudo 的 sudo 应用程序所在位置。通常 sudo 位于:

/usr/bin/sudo

所以你可以在脚本中写入:
/usr/bin/sudo shutdown -h 现在

As others mentioned you normally don't need to use sudo if you are already root. But if you write some scripts or something like that and need to run it when you use root and not root users you need to put the full part to your sudo command.
You can locate where sudo app is situated running whereis sudo from a non-root user. Normally sudo situated at:

/usr/bin/sudo

So you can write in your script:
/usr/bin/sudo shutdown -h now

上课铃就是安魂曲 2024-09-20 16:14:13

“我能以某种方式离开root吗?”

您可以创建另一个用户帐户,然后登录该帐户。

"Can I move out of root somehow?"

You could make another user account, and log into that.

跨年 2024-09-20 16:14:13

看来您根本没有安装 sudo:

未找到命令:sudo chmod +x /usr/local/bin/wkhtmltopdf

只需安装即可! sudo 应默认配置为允许 root 无需询问即可调用
对于密码...

Seems you simply don't have sudo installed:

command not found: sudo chmod +x /usr/local/bin/wkhtmltopdf

Just install it! sudo should be configured by default to allow being called by root without even asking
for password...

安静被遗忘 2024-09-20 16:14:12

如果您已经是 root,则不需要 sudo。只需删除 sudo 这个词即可。

sudo 是一个以普通用户身份获取 root 访问权限的工具。

You don't need sudo if you already are root. Just remove the word sudo.

sudo is a tool to get root access as a normal user.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文