1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mount Windows Share with R/W Permissions

Discussion in 'Linux & Open Source' started by maj, Jun 8, 2019.

  1. maj

    Wise Guy

    Joined: Jul 19, 2010

    Posts: 2,256

    Location: Newcastle

    I've recently started using Linux and have a headless Ubuntu server which I would like to access a network drive on my server with write permissions. I can mount the network drive with the following command in my fstab file:

    Code:
    //IP Address/share /media/mountname cifs credentials=/home/username/.smbcredentials,iocharset=utf8,sec=ntlm 0 0

    I've also tried:

    Code:
    //IP Address/share /media/mountname cifs credentials=/home/username/.smbcredentials,uid=1000,gid=1000  0  0

    Where uid and gid matches my ubuntu username details using 'id username' command.

    My .smbcredentials file contains the Windows username and password on my Windows server which has r/w permissions to the shared drive:

    Code:
    username=wUsername
    password=wPassword
    

    If I putty onto the Linux server I can view the Windows share at the mount point but if I try to create a test.txt file on the mount point using 'touch' command I get denied permission.

    How do I map a Windows share with r/w permissions?
     
  2. memyselfandi

    Sgarrista

    Joined: Oct 10, 2005

    Posts: 8,395

    Location: Nottingham

    Try using the following options as appropriate (note wrapped) :

    Code:
    //nas07/Pictures        /mnt/pictures cifs rw,_netdev,iocharset=utf8,credentials
    =/root/.creds,dir_mode=0755,uid=1000,gid=1000,vers=3.0 0 0
    
    (This is from the fstab file on one of my Linux boxes which is mounting a Windows/Samba share off of one of the NASes)
     
  3. maj

    Wise Guy

    Joined: Jul 19, 2010

    Posts: 2,256

    Location: Newcastle

    Thanks. Meant to reply earlier but only just managed to get this working how I want.

    That seemed to work in the extent that if I logged in via putty as my local user I could create files/folders at the mount point and also move files to it which is what I wanted. This particular server has a system account which I also required to have R/W permissions to the mount point which it didn't seem to have. Was messing on with chmod etc to no avail.

    To fix it I amended the fstab line so the uid is the system account and it seems to work how I want it. Not sure how I didn't think to do that earlier but main thing is it is now working.