4

I've used Ubuntu on VirtualBox for a while. Since I've upgraded to Windows 10, I thought it could be a good occasion to simplify my work and use the Ubuntu on Windows (the Unix command) you can install on Windows 10, so I don't have to start VirtualBox, transfer files, etc. each time I want to use Ubuntu.

Nonetheless, I am not sure I understand how I'm supposed to efficiently use this functionality.

Precisely:

  • Is there an (easy) way I can access my Windows 10 files (let's say a .txt file in Documents and Settings) from Bash? I have found my files through Bash, but it's returning Permission denied when I try using a ls command, even when I right-click Bash on Ubuntu and Run as administrator. Is there a way I can solve this?
  • Assuming that I can access files, can I then run Windows 10 programs through Bash? Or should I install the Linux versions?
  • I would recommend limiting the scope of your question to the file permissions part, as the 2nd is broad. – Jeff Schaller Feb 16 '17 at 23:26
  • Thanks. I re-wrote the second part to be more specific; I hope that looks alright. – francoiskroll Feb 16 '17 at 23:31
3

You can access outside files through the DrvFS /mnt tree. /mnt/c corresponds to your C: drive, and has the same layout. All files that your user can access are available through this filesystem, and the permissions are translated across somewhat intuitively:

In order to give the user a hint about the permissions they have on files, DrvFs checks the effective permissions a user has on a file and converts those to read/write/execute bits, which can be seen for example when running “ls -l”. However, there is not always a one-to-one mapping; for example, Windows has separate permissions for the ability to create files or subdirectories in a directory. If the user has either of these permissions, DrvFs will report write access on the directory, while in fact some operations may still fail with access denied.

It is possible that these can be somewhat different than expected, particularly if you have custom ACLs applied, or are accessing files through an elevated/non-elevated terminal (for example, Windows has more fine-grained creation permissions than the conventional Unix octal permissions, and WSL doesn't map onto Linux ACLs). The only permission you can usefully change is write (w) access, which affects the read-only flag on the NTFS file.


You can launch Windows programs from Bash provided that you are using at least version 14951, which has been available through the Insider programme since last year and will be in the next Windows release. You just need to find and execute the relevant executable as normal; you must be inside a DrvFS path to do so.


It's possible to combine these together:

$ export PATH=$PATH:/mnt/c/Windows/System32
$ cd /mnt/c/Users/you
$ notepad.exe file.txt

You can't (yet, perhaps ever) have Windows executables read from Linux files. Starting the executable from WSL will just fail, but trying to access the file a different way will just make everything break.

|improve this answer|||||
2

You might try https://www.cygwin.com/ to be able to use a bash terminal inside your windows. You can also see from that terminal the file permissions on the files you have permissions lacking on.

|improve this answer|||||
  • Thank you, I'm gonna look into that. Any drawbacks using Cygwin vs using Ubuntu on Windows? What's the difference between the two? – francoiskroll Feb 16 '17 at 23:22
  • That's a whole new question. I I suspect it's also too broad as with here. FWIW I use Cygwin daily, but I also run Debian under VirtualBox on the same Windows PC daily. Different tools albeit similar. – roaima Feb 16 '17 at 23:50
2

You should be able to find your files in the mnt directory on Bash for Windows. (e.g. /mnt/c/)

If there are permissions errors you can check using ls -l This will give you the rwx (read, write, execute) permissions in order from left to right signifying owner, group, all others

Keep in mind that Bash for Windows is meant to be a developmental feature, it's not intended to replace virtualizing an entire distribution like you would on VirtualBox. Plenty of things (like devices) don't work properly as they would in VirutalBox.

You can't run Windows 10 programs through the Bash shell. You can only run a limited amount of Linux programs as well (using apt-get to install them, for example). This is due to the above mention that it's crippled compared to VirtualBox by design

I'm sure there are many that use it, it was originally intended for developers to to have the ability to test their Linux code on a Windows machine.

|improve this answer|||||

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.