Score:-1

How do I give a .cpp file to my new user

kh flag

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?

Rishon JR avatar
pl flag
Try using rsync
hr flag
I'd suggest transferring it via the Windows filesystem located under `/mnt` - see for example [Can I change directory to a Windows drive in Ubuntu Bash on WSL?](https://askubuntu.com/questions/831361/can-i-change-directory-to-a-windows-drive-in-ubuntu-bash-on-wsl)
Score:0
vn flag

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
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.