Score:0

How do I write to a network share without using sudo

ug flag

I have a Ubuntu 22.10 server build that I have mounted a TrueNAS network share to with CIFS in fstab with the AD credentials that work on the TrueNAS box and I can see all the files and folders fine and it will mount automatically on startup.

I can only write to those folders if I use sudo though.

How can I get my normal user to write to the network share?

This is the line in fstab that I'm using

//10.1.1.4/Downloads /mnt/mars cifs user=USER,pass=PASSWORD 0 0

I also tried to add this to see if it would work for me after seeing another post

file_mode=0777,dir_mode=0777

Thanks in advance

Score:0
ug flag

After more searching and help from a user who has since deleted their comment because they made it an answer I found what I was doing wrong and sorted it out.

I put

file_mode=0777,dir_mode=0777

at the end of the line in fstab which was incorrect.

I now have it looking like this

//10.1.1.4/Downloads /mnt/mars cifs nofail,file_mode=0777,dir_mode=0777,user=USER,pass=PASSWORD 0 0

This has changed the mount point /mnt/mars to be rwxrwxrwx root root and my Docker container can now write what it needs too.

I also added the nofail just incase the share is offline

cn flag
don't use 777. Use at maximum 775 and you should prefer 750. "others" have nothing to do on your mounts so don't let them. If that is an issue you have another problem anyways: like a service not correctly set up, "group" should only have execute permissions if you have more than 1 user that share a group. "root root" is also bad; "Docker container" should be setup not using root to have a better security model.
Matt avatar
ug flag
Yeah someone else on reddit said the same thing. I plan on adding the user id and group id into the line to lock it down a bit more
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.