8

I am trying to access a win7 machine that has sharing enabled on a folder. When I mount it on linux it lists all files as -rwxr-xr-x 1 root root

If i sudo i can copy files back and forth but its read only if I dont.

sudo chown [standard_user] * on the mounted share does nothing.

This mounts the share as read only (all files are root) sudo mount -t cifs "//myipaddress/myshare" /home/myuser/mymount/ -o username=myusername,password=mypassword,rw

On the win7 box I have myuser and everyone as 'full control'

how do I mount this share so that I dont have to be root to delete/move files?

5 Answers 5

14
mount -t cifs "//myipaddress/myshare" /home/myuser/mymount/ -o username=myusername,password=mypassword,uid=myusername,gid=users
8
  • If an answer helps you, accept it by clicking on the small grey tick/check beneath the number on the left hand side of the answer @flashc5 , once you have enough reputation you can upvote too. All this information is in the tour, reading it will also get you your first badge woo-hoo!
    – Arronical
    Mar 7, 2017 at 17:16
  • i alsways do, it makes you wait so many minutes before you can mark it as the answer
    – flashc5
    Mar 7, 2017 at 17:25
  • This worked, but all the files created through the mount are now -rwxrwxrwx. Is there a way to change this? Sep 10, 2018 at 18:34
  • @RogierLommes I do not think that this is possible on a per file basis (as MS file systems do not support linux file permissions).
    – Bruni
    Sep 11, 2018 at 6:27
  • 1
    Sometimes it doesn't work when you specify myusername and users, but instead with 1000 and 1000 Aug 15, 2023 at 14:02
4

Try the following. Works fine for me.

sudo mount -t cifs -o vers=1.0,username=myuser,pass=mypass "//myipaddress/myshare" /home/myuser/mymount/
1
  • 1
    obsolete answer, does not work for Ubuntu 21.04
    – jbarlow
    May 13, 2021 at 0:15
1

I faced this issue on Ubuntu 22.04 in 2022. And found the solution here How to Mount Windows Share on Linux using CIFS

I added below entry in /etc/fstab file so as to auto mount the shared folder during boot

//192.168.x.x/mysharedfolder /home/myubuntuuser/mysharedfolder cifs vers=3.0,credentials=/path-to/.credentials,uid=1000,gid=1000,dir_mode=0755,file_mode=0755

In the above fstab entry uid and gid is user id and group id of myubuntuuser, which can be found using id command on terminal. dir_mode and file_mode provide the file/folder permissions during mount.

0

vi /user/credfile username=user password=pass domain=mydomain.local

vi /etc/fstab //192.168.86.23/Share /mnt/Share cifs credentials=/user/credfile,_netdev 0 0

mount -a

-1

You have to make sure the mounting target is owned by the user/group first.

Change directories ownership

sudo chown myusername:mygroupname /mymount/

Mount it to home dir

mkdir ~/mymount
sudo mount /path/to/partition ~/mymount
2
  • while this solution is correct, I would advise against blindly changing permissions/ownership of files/directories if you don't know what you're doing
    – j-money
    Mar 27, 2019 at 10:23
  • Answer is not only incorrect, but is missing the required '-R' (recursive) option to chown.
    – Raleigh L.
    Aug 20, 2022 at 5:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .