-1

I'm trying to run a .cpp file on Ubuntu. I'm on a Windows computer and downloaded Ubuntu from the microsoft store. Problem is, I couldn't safely run my program on my root (reasons dont matter) and had to run it on another user. So, I created a new user ("noroot") and am trying to put my .cpp on there. But if I click on my new user, or try and manually swipe my file in the folder, I get this message:

''' \wsl.localhost\Ubuntu\home\notroot is not accessible. You might not have permission to use this network resource. Contact the administrator to find out if you have access permissions.

Attempt to acces invalid address. '''

And I just can't find out how to get my file on there. Can anyone help?

1 Answers1

0

When Ubuntu is installed under WSL, you are asked for a default username and password. This default user is the one that "owns" the shares. If that default user doesn't have access to a file, then you will not be able to access it through \\wsl.localhost\Ubuntu. The default access permissions for other users' home directories (such as this "noroot" user) are drwxr-x---, which means that anyone outside the user or their group will not have access.

You should be using that default user for almost all actions in Ubuntu. However, it sounds like you have been using the root user for some reason. It's unclear from your question why that's the case.

One possibility that I can think of is that perhaps you were installing Ubuntu and missed the final prompt for that default user/password. In that case, it wouldn't have been created, and the root user would become the default. See this answer for how to correct that. You've apparently done some of those steps already, but make sure you have the permissions correct.

Most importantly, you probably need to create the /etc/wsl.conf as mentioned in that answer to set noroot (or whatever you really want your username to be) to be the default user.


Apart from the user/ownership issues, you could (and probably should) be copying the file directly in Ubuntu, rather than using Windows File Explorer. Let's say that you had the file in your root user's home directory and you wanted to move it to to the noroot user's home directory. That would look something like:

As the root user:

cp /root/file.cpp /home/noroot/
chown noroot:noroot /home/noroot/file.cpp

Or as the regular user:

sudo cp /root/file.cpp /home/noroot/
sudo chown noroot:noroot /home/noroot/file.cpp

As @steeldriver mentioned in the comments, if the file is currently on the Windows drive, then that might look like:

sudo cp /mnt/c/home/yourwindowsuser/Documents/projects/file.cpp /home/noroot/
sudo chown noroot:noroot /home/noroot/file.cpp
NotTheDr01ds
  • 17,888