WSL/bash-on-windows- sudo broken after release upgrade

2

I know I'm not supposed to run do-release-upgrade in WSL, but I did it anyway. The upgrade itself went without errors, but any attempt to run sudo returns:

sudo: no tty present and no askpass program specified

The output of ls -l /dev as a regular user:

ls: cannot access 'lxss': Operation not permitted
ls: random: Invalid argument
ls: tty: Invalid argument
ls: tty0: Invalid argument
total 0
drwxr-xr-x 2 root     root      0 Aug 15 19:27 block
lrwxrwxrwx 1 root     root     13 Aug 15 19:27 fd -> /proc/self/fd
crw------- 1 root     root   0, 0 Aug 15 19:32 kmsg
c????????? ? ?        ?         ?            ? lxss
crw-rw-rw- 1 root     root   1, 3 Dec 31  1969 null
crw-rw-rw- 0 root     tty    5, 2 Aug 15 19:28 ptmx
drwxr-xr-x 0 root     root      0 Aug 15 19:27 pts
crw-rw-rw- 1 root     root   1, 8 Aug 15 19:32 random
lrwxrwxrwx 1 root     root      8 Aug 15 19:27 shm -> /run/shm
lrwxrwxrwx 1 root     root     15 Aug 15 19:27 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root     root     15 Aug 15 19:27 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root     root     15 Aug 15 19:27 stdout -> /proc/self/fd/1
crw--w---- 0 me tty  136, 0 Dec 31  1969 tty
crw-rw-rw- 1 root     tty    4, 0 Aug 15  2016 tty0
crw------- 1 me tty    4, 1 Aug 15  2016 tty1
crw-rw-rw- 1 root     root   1, 9 Aug 15 19:32 urandom
crw-rw-rw- 1 root     root   0, 0 Aug 15 19:32 zero

Running as root(using lxrun.exe/setdefaultuser) returns the same thing.

I know I can just reinstall Ubuntu, but I'm still curious as to what might be causing the problem and if there's an easy fix.

Oh- and date returns Mon Aug 15 19:45:49 DST 2016, like it should.

Anton Liakhovitch

Posted 2016-08-16T02:42:08.007

Reputation: 571

Answers

2

What might help as an alternative to downloading older packages:

  • Log in as Root, via lxrun /setdefaultuser root, or (if you have not upgraded yet) sudo su
  • Set a password for the Root user via passwd

Now you can always switch to root by simply using su root and entering the password you have set, without having to toggle the default user via lxrun.

As an alternative, you can prevent sudo from requiring a password at all, as mentioned in several answers here:

To prevent sudo from asking a password at all, you can add the following line at the end of your /etc/sudoers file (use visudo as root to edit the file)

<username> ALL=(ALL) NOPASSWD: ALL

Be advised, this will cause sudo to no longer ask for a password at all, when executing any Sudo command. If you want to limit the programs that can be used using sudo, add the full path to the binaries (comma separated) instead of the final ALL, eg.:

<username> ALL=(ALL) NOPASSWD: /usr/sbin/cron, /usr/sbin/visudo

Leon Hagendijk

Posted 2016-08-16T02:42:08.007

Reputation: 36

Nearly 1 year later: +1, but the above is the best and easiest answer. – Fabby – 2017-10-18T01:53:47.623

Wow. I forgot that I had even asked this. A year later, I'm using OpenSUSE as my main OS with a Windows installation running in KVM for those occasional use cases. However, this answer is what I would've done now had I still been struggling with that problem. – Anton Liakhovitch – 2017-12-21T04:30:24.423

2

Found a solution here:

From cmd:

lxrun /setdefaultuser root

From bash as root:

wget http://mirrors.kernel.org/ubuntu/pool/main/s/sudo/sudo_1.8.9p5-1ubuntu1.1_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.1_amd64.deb
dpkg -i procps_3.3.9-1ubuntu2_amd64.deb
dpkg -i strace_4.8-1ubuntu5_amd64.deb

Don't forget to set your non-root default user after your done!

lxrun /setdefaultuser <your user>

schnatterer

Posted 2016-08-16T02:42:08.007

Reputation: 123

The mirrors listed above don't work for me, but I've found these working:

<pre> wget https://mirror.hmc.edu/ubuntu/pool/main/s/sudo/sudo_1.8.9p5-1ubuntu1.1_amd64.deb wget https://mirror.hmc.edu/ubuntu/pool/main/s/strace/strace_4.8-1ubuntu5_amd64.deb </pre>

I couldn't downgrade procps because of missing libprocps3, so I used

<pre>https://mirror.hmc.edu/ubuntu/pool/main/p/procps/procps_3.3.12-1ubuntu2_amd64.deb<pre> – David Lukac – 2018-09-24T13:27:33.010

-1

From cmd:

ubuntu config --default-user root

To run WSL in the current Windows command prompt

ubuntu.exe

To see the last three users added to the Ubuntu system

tail -3 /etc/passwd

To change the password for user01

passwd user01

To exit WSL

exit

Roman

Posted 2016-08-16T02:42:08.007

Reputation: 1

This answer suggests a method that would only work for 1709+, which was released a full year after the question was asked and thus is not applicable to this question. – Ramhound – 2018-11-22T16:33:10.240

1My response is addressed to new WSL users first. For now all solution above are already outdated. So I hope my answer will help someone who have more modern build of W10 but have same issue as author of question(with unavailability to run "sudo" and "sudo -s", etc). – Roman – 2018-11-28T18:56:04.500