【发布时间】:2015-04-14 13:41:54
【问题描述】:
这个问题有点具体,我想做下面代码的等价物:
# these commands must be run as root
root@server:$ useradd -m -s /bin/bash elspeth # add user named elspeth
# -m creates a home folder, -s sets elspeth to use bash by default
root@server:$ usermod -a -G sudo elspeth # add elspeth to the sudoers group
root@server:$ passwd elspeth # set password for elspeth
root@server:$ su - elspeth # switch-user to being elspeth!
elspeth@server:$
elspeth@server:$ sudo apt-get install nginx
elspeth@server:$ sudo service nginx start
我在打开命令提示符时单击“以管理员身份运行”,我假设它是“以 root 身份运行”。
我做了一些研究,发现像 net user (username) (pwd) 这样的命令,我认为这些命令是 Windows 等效的。现在首先,我很困惑的 sudo 组部分。我输入:
net localgroup sudo (user) /add
但是得到一个“指定的本地组不存在”。我是否要创建一个新的“sudo”组?
还有一部分代码将用户设置为“默认使用 bash”,我不知道/理解 Windows 等效项。
最后,对于第一段代码,有一个 su 命令。 runas 是等价的吗?我读到您可以通过 runas 从 Windows 上的命令提示符切换用户,但是我必须指定要运行的程序(在这种情况下是 bash 吗?)
根据我在 StackOverflow 上读到的内容,runas 实际上是 Windows 等效于 Linux 的 sudo,在我们拥有的第二段代码中,这让我更加困惑使用 sudo (对于它的价值,sudo 对我来说是一个无法识别的命令)。
作为参考和上下文,这是我正在使用的书以及处理此代码的确切摘录: http://chimera.labs.oreilly.com/books/1234000000754/ch08.html#_user_accounts_ssh_and_privileges
【问题讨论】:
-
没有与该代码的大部分功能相当的特别接近的 Windows。为什么您尝试遵循为 Linux 设计的说明,而不是为 Windows 设计的说明?你真正想要达到什么目的? (例如:在 Windows 中没有任何东西相当于 sudo 组,不需要为用户分配特定的 shell,通常不需要类似 sudo 的命令等)
标签: linux windows bash command-line sudo