1

Before moving, I checked the directory and it had all the contents in it. Then I moved it to a directory in my C drive (I'm using WSL) with this command: sudo mv c_dir/ mnt/c/Users/L570/Documents/to_be_compiled/

When I cded my way into to_be_compiled, it certainly was there. But it was empty.

I found this command: chown erebus /mnt/c/Users/L570/Documents/to_be_compiled/c_dir/ on another question, but that didn't change anything either.

I tried ls -a, but there really are no files inside.

Question: Have I lost all the files, or is it about permissions?

9
  • 1
    The question and the prose are at odds. Did you copy or move the file? Was it a file or directory?
    – DopeGhoti
    Dec 21, 2022 at 6:02
  • @DopeGhoti remedied it. It was a directory. I moved it.
    – Haris
    Dec 21, 2022 at 6:16
  • as long as you are in the / root folder when you ran that command, then that looks like a valid move ... at least in WSL2 Dec 21, 2022 at 6:37
  • No one knows what happened. Dec 21, 2022 at 6:56
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Dec 21, 2022 at 11:43

1 Answer 1

1

I think it's safe to say from the comments that we're all confused on exactly what happened in this case based on the current information. If it helps, I wasn't able to reproduce your issue using the following scenario in Ubuntu on WSL:

cd /
sudo mkdir c_dir
cd c_dir
sudo touch abc 1 2 3
cd /
sudo mv c_dir/ mnt/c/Users/ntd/Documents/to_be_compiled

The directory /c_dir was renamed (moved) to the to_be_compiled directory in the proper location, with all files present.

That said, best practice would certainly be to use the fully qualified directory names (starting with a /) rather than the relative form that you used. I'm wondering if perhaps the files are someplace else based on your working directory when you ran the mv command.

Note that the actual ownership and permissions will vary depending on whether you have changed the automount settings in /etc/wsl.conf.

With a default WSL installation, the files will be owned by your user once they are moved to the Windows drive, with 777 permissions.

I have mine changed slightly, with the following in /etc/wsl.conf:

[automount]
options = "metadata,umask=22,fmask=11"

With that in place, WSL attempts to mimic the actual Linux ownership and permissions, so the files are owned by root (since they were moved with sudo) and the permissions are 644.

4
  • The file permissions are 500 right now. Interestingly, I was not able to reproduce the same problem when I experimented with it. But what I forgot to mention was that, the file originally resided in a folder on the C disk, which I accidentally moved to the root directory. I can still see the files in Windows File Explorer's "Frequent Folders", but upon opening them, I see a prompt saying "Location is not available."
    – Haris
    Dec 22, 2022 at 17:37
  • @Haris Hmm - When you accidentally moved them, what were you using? Windows File Explorer? Using the \\wsl.localhost\<distro_name> or \\wsl$\<distro_name> path? That shouldn't have been possible, since WSL should treat Windows application as running as your WSL user, not root. Since your regular user shouldn't have access to / in Linux, that move should have been denied. Is there any chance that the files were actually moved to a different location? Perhaps somewhere under your /home/<username> folder in WSL? Dec 22, 2022 at 18:09
  • @Haris If you know the name of one of the missing files, try running sudo find / -xdev -name "filename" and see if you can find the missing files elsewhere. That will include every location in WSL, but not on the Windows drive. Dec 22, 2022 at 18:12
  • 1
    Update: Running that command in WSL failed. But running a similar command in windows cmd succeeded. It seems that the command created a directory c_dir in C:\c_dir\. Thank you.
    – Haris
    Dec 23, 2022 at 17:04

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.