Windows Bash (WSL) - sudo:不存在 tty 且未指定 askpass 程序
Windows Bash (WSL) - sudo: no tty present and no askpass program specified
在遵循 this tutroial 之后,我在尝试 运行 作为用户甚至 sudo 命令时收到以下错误:
sudo: no tty present and no askpass program specified
这篇文章中 Lurdan 的评论表明您需要 运行
sudo -S <YOUR_COMMAND>
chmod 0666 /dev/tty
chmod
不起作用,但 sudo -S
起作用,但肯定还有另一个修复方法?
太傻了,往下看后我看到了来自Beorat的解决方案:
To avoid the sudo tty issue and others, run these commands just before running do-release-upgrade:
sudo -S apt-mark hold sudo
sudo -S apt-mark hold procps
sudo -S apt-mark hold strace
If you've already upgraded, run the above commands, then manually downgrade to the Trusty packages:
sudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/s/sudo/sudo_1.8.9p5-1ubuntu1.1_amd64.deb
sudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/p/procps/procps_3.3.9-1ubuntu2_amd64.deb
sudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/s/strace/strace_4.8-1ubuntu5_amd64.deb
sudo -S dpkg -i sudo_1.8.9p5-1ubuntu1.1_amd64.deb
sudo -S dpkg -i procps_3.3.9-1ubuntu2_amd64.deb
sudo -S dpkg -i strace_4.8-1ubuntu5_amd64.deb
更多信息在这里:https://github.com/Microsoft/BashOnWindows/issues/482
WSL 使用 lx运行 可执行文件进行管理 Windows:
lxrun -h
Usage:
/install - Installs the subsystem
Optional arguments:
/y - Do not prompt user to accept
/uninstall - Uninstalls the subsystem
Optional arguments:
/full - Perform a full uninstall
/y - Do not prompt user to accept
/setdefaultuser - Configures the subsystem user that bash will be launched as. If the user does not exist it will be created.
Optional arguments:
username - Supply the username
/y - If username is supplied, do not prompt to create a password
/update - Updates the subsystem's package index
鉴于此,您可以使用 lxrun /setdefaultuser root
。只是想我会指出它的这一面,因为当我 运行 在尝试升级到 Xenial 后遇到与您相同的问题时,它是必需的。我可以确认 运行ning this command,然后 wget / dpkg 命令解决了我的问题。
我使用的命令:
wget http://mirrors.kernel.org/ubuntu/pool/main/s/sudo/sudo_1.8.9p5-1ubuntu1.4_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/p/procps/procps_3.3.9-1ubuntu2_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/s/strace/strace_4.8-1ubuntu5_amd64.deb
dpkg -i sudo_1.8.9p5-1ubuntu1.4_amd64.deb
dpkg -i procps_3.3.9-1ubuntu2_amd64.deb
dpkg -i strace_4.8-1ubuntu5_amd64.deb
最后,您可能需要 运行 sudo apt-get install -f
以防您得到 The following packages have unmet dependencies [xxx] but it is not going to be installed
我通过将 /etc/hosts 移动到 /etc/hosts.bu 来消除错误。关闭 shell en 再次打开后,会重新创建 /etc/hosts 并添加您的计算机名称。错误消失了(对我来说。)
在遵循 this tutroial 之后,我在尝试 运行 作为用户甚至 sudo 命令时收到以下错误:
sudo: no tty present and no askpass program specified
这篇文章中 Lurdan 的评论表明您需要 运行
sudo -S <YOUR_COMMAND>
chmod 0666 /dev/tty
chmod
不起作用,但 sudo -S
起作用,但肯定还有另一个修复方法?
太傻了,往下看后我看到了来自Beorat的解决方案:
To avoid the sudo tty issue and others, run these commands just before running do-release-upgrade:
sudo -S apt-mark hold sudo
sudo -S apt-mark hold procps
sudo -S apt-mark hold strace
If you've already upgraded, run the above commands, then manually downgrade to the Trusty packages:
sudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/s/sudo/sudo_1.8.9p5-1ubuntu1.1_amd64.deb
sudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/p/procps/procps_3.3.9-1ubuntu2_amd64.deb
sudo -S wget http://mirrors.kernel.org/ubuntu/pool/main/s/strace/strace_4.8-1ubuntu5_amd64.deb
sudo -S dpkg -i sudo_1.8.9p5-1ubuntu1.1_amd64.deb
sudo -S dpkg -i procps_3.3.9-1ubuntu2_amd64.deb
sudo -S dpkg -i strace_4.8-1ubuntu5_amd64.deb
更多信息在这里:https://github.com/Microsoft/BashOnWindows/issues/482
WSL 使用 lx运行 可执行文件进行管理 Windows:
lxrun -h
Usage:
/install - Installs the subsystem
Optional arguments:
/y - Do not prompt user to accept
/uninstall - Uninstalls the subsystem
Optional arguments:
/full - Perform a full uninstall
/y - Do not prompt user to accept
/setdefaultuser - Configures the subsystem user that bash will be launched as. If the user does not exist it will be created.
Optional arguments:
username - Supply the username
/y - If username is supplied, do not prompt to create a password
/update - Updates the subsystem's package index
鉴于此,您可以使用 lxrun /setdefaultuser root
。只是想我会指出它的这一面,因为当我 运行 在尝试升级到 Xenial 后遇到与您相同的问题时,它是必需的。我可以确认 运行ning this command,然后 wget / dpkg 命令解决了我的问题。
我使用的命令:
wget http://mirrors.kernel.org/ubuntu/pool/main/s/sudo/sudo_1.8.9p5-1ubuntu1.4_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/p/procps/procps_3.3.9-1ubuntu2_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/s/strace/strace_4.8-1ubuntu5_amd64.deb
dpkg -i sudo_1.8.9p5-1ubuntu1.4_amd64.deb
dpkg -i procps_3.3.9-1ubuntu2_amd64.deb
dpkg -i strace_4.8-1ubuntu5_amd64.deb
最后,您可能需要 运行 sudo apt-get install -f
以防您得到 The following packages have unmet dependencies [xxx] but it is not going to be installed
我通过将 /etc/hosts 移动到 /etc/hosts.bu 来消除错误。关闭 shell en 再次打开后,会重新创建 /etc/hosts 并添加您的计算机名称。错误消失了(对我来说。)