在 26052 以下的 Windows 版本中使用 sudo 命令

Windows 11 Insider Preview Build 26052 中,Microsoft 为 Windows 添加了 sudo 命令,它可以让用户像在 Linux 中那样使用 sudo。但是这么好用的功能目前只能在 26052 中使用,这怎么行呢‽ 所以,这次我就要让 Windows 10 用上 sudo!

其实 sudo 就是靠 %SystemRoot%\System32\sudo.exe 实现的,那这就好办了啊,只要把它复制到其它版本的 Windows 中就行了

where sudo
where sudo

首先把 sudo.exe 复制到 Windows 10 的 %SystemRoot%\System32 下,如果你没有运行 26052 或以上的 Windows 的设备可以在此处下载

copy to system32
复制到 System32

以管理员身份运行命令提示符

run cmd as administrator
cmd,启动!

现在输入 sudo 会提示 sudo 没被启用

Sudo is disabled on this machine. To enable it, go to the Developer Settings page in the Settings app
Sudo is disabled on this machine. To enable it, go to the Developer Settings page in the Settings app

输入sudo config --enable <configuration_option>启用 sudo,其中<configuration_option>可填写forceNewWindowdisableInputnormal,分别对应“在新窗口中”、“禁用输入”、“内联”

sudo config --enable normal
sudo config –enable normal,启用内联模式
mode
三种模式

重新开一个没有管理员的命令提示符,可以正常显示帮助

sudo
正常显示帮助

输入sudo cmd会弹 UAC,点 Yes 后从标题栏可以看到已经是管理员了

UAC
UAC
Administrator
标题栏可以看到已经是 Administrator
FacebookXSina WeiboThreadsQzoneTelegram

《在 26052 以下的 Windows 版本中使用 sudo 命令》有3条评论

  1. 有一说一,毕竟是放进system32里,还是提权的,直接拿来用难免不放心。所以,我专门跑去下了完整镜像,提取出了sudo.exe,和博主给的确实是一样的。(为了910KB下载了4.83GB,啧啧啧)。
    在此贴出校验:
    SHA1:2c328c6a78195c6f9c5c16b43d6de026b33bfc45
    SHA256:45e25f27b0acd03035c9da063fe8867402ff5bcd2b181533e569c443a6f789dd
    校验于2024.2.16,提取自26058版本,sudo版本0.1.5。
    和我一样不放心的就到这里下完整镜像,自己拿sudo.exe吧,看网址也知道是微软官方的。
    https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewiso

    回复

发表评论