0

ls /usr/bin

gives the error message:

ls: reading directory '/usr/bin': Permission denied

on wbash.exe. For that reason bash-completion and eshell-completion fails or gives incomplete results. I would like to get it working.

Things that do work:

/usr/bin $ ls -l emacs
lrwxrwxrwx   1 root           root           23 2017-07-31 17:16 emacs -> /etc/alternatives/emacs
/usr/bin $ ls -l gcc-5
-rwxr-xr-x   1 root           root       915736 2017-09-14 06:01 gcc-5
/usr/bin $ ls -ld /usr/bin
drwxr-xr-x   0 root           root          512 2017-12-19 09:45 /usr/bin
/usr/bin $ ls -ld /usr/sbin
drwxr-xr-x   0 root           root          512 2017-12-19 09:45 /usr/sbin
/usr/bin $ ls -ld /
drwxr-xr-x   0 root           root          512 2017-11-17 10:23 /
/usr/bin $ ls -ld /usr
drwxr-xr-x   0 root           root          512 2017-03-30 11:55 /usr

Windows version is: Windows 10 (64bit), Version 1703 (Build 15063.786)

The sbin directory can be listed without problems and all windows settings of bin in %USERPROFILE%\AppData\Local\lxss\rootfs\usr available via WindowsExplorer are the same as that ones for sbin.

The commands icacls.exe bin and icacls.exe sbin within %USERPROFILE%\AppData\Local\lxss\rootfs\usr give exactly the same answer (up to the first word which is bin for bin and sbin for sbin). So it does not seem to be related to the extra attributes. Also the commands icacls.exe bin /verify and icacls.exe sbin /verify don't indicate any errors.

Is there maybe some security-related feature of ubuntu (I don't know of) that prohibits me to list the directory contents of /usr/bin? (In that case it would be strange if it didn't forbid the listing of /usr/sbin.)

  • what it the output of ls -ld / and ls -ld /usr ? – Giacomo Catenazzi Dec 21 '17 at 9:33
  • @GiacomoCatenazzi I added those two to the list. Nothing surprising there. – Tobias Dec 21 '17 at 9:36
  • So it seems to be because of extra attributes, look e.g. technet.microsoft.com/en-us/library/cc753525(v=ws.11).aspx – Giacomo Catenazzi Dec 21 '17 at 9:43
  • @GiacomoCatenazzi The commands icacls.exe bin and icacls.exe sbin give exactly the same answer (up to the first word which is bin for binand sbin for sbin). So it does not seem to be related to the extra attributes. Is that right? Or are there some nifty tricks to get even more information? icacls.exe bin /verify and icacls.exe sbin /verify doesn't output any errors. – Tobias Dec 21 '17 at 9:52
  • @GiacomoCatenazzi I can list the contents of bin (and sbin) without problems under windows (e.g., WindowsExplorer or PowerShell dir bin or ls bin) – Tobias Dec 21 '17 at 9:55
0

It looks very much like a permissions problem.

As you have verified that the problem is not with Windows, then this problem is with WSL internal settings, where it emulates Linux permissions which do not natively exist on Windows.

I don't know exactly how WSL does its emulation of Linux permissions. If it uses the Windows mechanism of ACL, you could reset them all by :

icacls %localappdata%\lxss /reset /T /C

If this does not help, and without better knowledge of how these permissions are implemented, I would suggest to reinstall WSL :

  1. Backup your data

  2. Uninstall the Ubuntu environment but keep your home folder, then reinstall WSL, by using the commands :

    lxrun /uninstall
    lxrun /install
    
  3. If this did not help, fully reinstall the Ubuntu environment including removing your home folder, by entering :

    lxrun /uninstall /full
    lxrun /install
    

In-between the two above commands, check that the folder %localappdata%\lxss is empty. If not, move its contents to temporary storage and delete later when no longer required.

  • Lxrun is deprecated now. – Biswapriyo Dec 23 '17 at 5:17
  • @Biswa: This is for the upcoming Windows build 16215. lxrun is the current method, and most likely will continue to be available for some time. – harrymc Dec 23 '17 at 7:10
0

There are no permission problems with cygwin under $HOME/AppData/Local/lxss/rootfs/usr/bin and I did some tests with playground folders of wsl under cygwin. That lead me to the following solution.

In the bash of cygwin I went to $HOME/AppData/Local/lxss/rootfs/usr and run the following command:

find bin -mindepth 1 -maxdepth 1 -printf "cp -a %p fix/%p\n" > /temp/fix.sh

That created a script /temp/fix.sh in a folder /temp that is shared between cygwin and wsl via symbolic links.

In wbash I went to /usr/, created the folders fix and fix/bin, run the script, and moved the directory fix/bin to bin-fix.

cd /usr
mkdir -p fix/bin
. /temp/fix.sh
mv fix/bin bin-fix

Thereby, wbash told me that it had permission problems for bin/head. Okay, I accepted that and re-installed coreutils as a last step of this procedure (see below). Next I closed all wbash applications and wbash itself and went back to cygwin where the usr folder was still open.

There I moved bin out of the way and re-named bin-fix to bin.

mv bin bin.old
mv bin-fix bin

I re-started wbash and voilá everything runs fine and ls /usr/bin works.

As I already mentioned above I re-installed coreutils as a last step:

sudo aptitude reinstall coreutils

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.