Ubuntu 服务器上的 runuser 命令在哪里?

use*_*220 5 linux ubuntu permissions

当我在控制台中输入“runuser”时,我收到“找不到命令”。我虽然这个命令很标准,但我在我的系统上找不到它。

我是 root 用户,但我没有其他用户的密码。

l0b*_*0b0 6

在Ubuntu你susudo对这样的事情:

su - username
Run Code Online (Sandbox Code Playgroud)

更改为 user username,就像该用户已登录一样。

sudo -u username command
Run Code Online (Sandbox Code Playgroud)

以 user 身份运行单个命令username

  • 谢谢。但是,我正在寻找 runuser 函数,因为我没有其他用户的密码。 (3认同)

Tha*_*Guy 4

根据您对其他答案的评论:

当我这样做的时候su - otheruser,我就得到了No directory, logging in with HOME=/。然后当我跑步时whoami,我明白了root

发生这种情况是因为“otheruser”没有 shell(如 bash)。它可能类似于 /bin/false。如果您想要一个 shell 作为“otheruser”,请使用以下命令:

sudo -u otheruser /bin/bash
Run Code Online (Sandbox Code Playgroud)