Permission denied when trying to 'mv' a directory
I think that a service or a program of windows is perhaps using or accessing the same file , i used to have the same problem when i first installed the linux subsystem on windows 10.
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
Situation:
- I am using Bash with Linux subsystem for Windows(10); I am logged in as root.
- All folders and files in my current directory have rwxrwxrwx, and the same is true for descendant files and folders.
- There is no system file in my current directory nor in the descendants.
- None of folders is synchronized with git.
Problem:
- I cannot change the name of one particular directory. However I can do
this for every single other directory or file - whether in the current
directory, or inside the un-
mv
-able directory in question.
I can copy a whole directory to another one and then freely change its name, or I can copy its contents to the folder with the desired name, and those solutions are acceptable, but using just
mv
would be easier. For the sake of knowledge - as abash
and Linux beginner - I really would like to understand the problem.
Additional info as requestedroot@MARVIN:/mnt/h/testing# mv test1.pl otherName mv: cannot move ‘test1.pl’ to ‘otherName’: Permission denied
root@MARVIN:/mnt/h/testing# lsattr test1.pl lsattr: Inappropriate ioctl for device While reading flags on test1.pl/css lsattr: Inappropriate ioctl for device While reading flags on test1.pl/fonts lsattr: Inappropriate ioctl for device While reading flags on test1.pl/index.html lsattr: Inappropriate ioctl for device While reading flags on test1.pl/index2.html lsattr: Inappropriate ioctl for device While reading flags on test1.pl/index3.html lsattr: Inappropriate ioctl for device While reading flags on test1.pl/index4.html lsattr: Inappropriate ioctl for device While reading flags on test1.pl/index5.html lsattr: Inappropriate ioctl for device While reading flags on test1.pl/js lsattr: Inappropriate ioctl for device While reading flags on test1.pl/notes.txt
Given various operations I was doing on partition directory resides on, I guess it is not read-only, but for the record:
root@MARVIN:/mnt/h/testing# mount rootfs on / type rootfs (rw,relatime) sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000) tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=204320k,mode=755) none on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k) none on /run/shm type tmpfs (rw,nosuid,nodev,relatime) none on /run/user type tmpfs (rw,nosuid,nodev,noexec,relatime,size=102400k,mode=755)
SolutionThe directory was in fact blocked by Atom editor (installed on Windows not WSL).
Details
The directory in question is directory A.
- If one of files Aa, Ab, Ac is opened in the editor, I can
mv
Dir A. - If one of files AAa ... ABc is opened I get
Permission denied
. - If contents of Dir A are visible it Atom project browser, I can
mv
it. - If contents of Dir AA or Dir AB are visible in Atom p. b., I get
Permission denied
.
-
Admin about 7 yearsdo
lsattr <directory>
please and share the output -
Admin about 7 yearsDoes your unmovable files is residing in any readonly partition?
-
Admin about 7 yearsQuestion was updated with all requested info.
-
Admin about 7 yearsDoes
otherName
already exist (including all variations, capitalized or not)? Havetest1.pl
orH:\testing
recently been modified by an ordinary (non-WSL) Windows program? -
Admin about 7 years
otherName
does not exist; sibling-directories to the directory in question could have their names changed tootherName
without a problem. About the modification - AFAIK: no. I may add thattest1.pl
is directory for the virtual host of Apache, but still, as well are neighbouring directories that could bemv
-ed freely. -
Admin about 7 yearsI have inadvertently killed experimental subject. To verify if directory is attached to some Windows service I copied it and tried to remove it - sadly not with Windows "delete" but
rm -r
. Much to my surprise directory vanished without a single objection. I then renamed the copy of directory to the original nametest1.pl
and now I obviously canmv
it, but further troubleshooting may be difficult. I will report if the problem will come back after next reboot. -
Admin about 7 yearsIf this happens again, try renaming it in windows explorer - it might give a more precise error message.
-
Admin about 7 years@Mark Plotnick I updated my question. I guess your suggestion that Windows program modifies this directory was correct, but - at least for me - it was happening in a hard to notice way.
-
Admin over 4 years
-
raphaklaus over 3 yearsIn my case, I just closed VSCode and it worked.