2

On Windows 10 within my Ubuntu Subsystem, when I open a file in a directory and try to rename that directory while that file is open, I am unable to do so.

Example:

$mkdir demo
$touch demo/test.txt
$CtlZ
$[2]+  Stopped                 vim demo/test.txt
$mv demo demo100
mv: cannot move 'demo' to 'demo100': Permission denied

And now when I close the file I can rename it.

$mv demo demo100
$ls demo100
test.txt

This seems like unexpected behavior. When I do the same test on a regular Ubuntu box, I am able to rename the file without a problem. Any ideas as to what might cause this?

1 Answer 1

3

Yes, this is normal Windows behaviour. Under windows, opening a file effectively locks it on the file system and prevents it from being moved.

It's important to understand that WSL is NOT a virtual machine. It is a (thin) layer on top of windows which gives Posix like access onto windows. So when you open a file under WSL, you are in fact opening it under windows and are subject to the usual rules of windows.

Reading:

https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux

Overview

WSL provides a Linux-compatible kernel interface developed by Microsoft (containing no Linux kernel code), which can then run a GNU user space on top of it, such as that of Ubuntu, openSUSE, SUSE Linux Enterprise Server, Debian and Kali Linux.

Further

Hardware and filesystem access

As there is no hardware emulation / virtualization (unlike other projects such as coLinux), WSL makes direct use of the host file system

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .