Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have two users A and B on a remote ubuntu box (+ a bunch more). I now ssh to the machine with user A. Then I change to user B:

su B

and run

sudo mount -a

This mounts a windows fileshare that I specified in /etc/fstab:

//windowsshare/backup/tmp /media/backup/ cifs guest,uid=1000,iocharset=utf8,codepage=unicode,unicode 0 0

Even though I mounted the drive as user B its user A that owns the folder:

B@ubuntu:/media$ ll
totalt 16
drwxr-xr-x  5 root    root 4096 dec 27 12:15 ./
drwxr-xr-x 23 root    root 4096 jun  8  2012 ../
drwxr-xr-x  1 A root    0 dec 21 11:06 backup/
drwxr-xr-x  2 root    root 4096 jun  8  2012 cdrom/
lrwxrwxrwx  1 root    root    7 jun  8  2012 floppy -> floppy0/
drwxr-xr-x  2 root    root 4096 jun  8  2012 floppy0/

I have tried to run (still as user B):

sudo chown -R B backup

But I still get the above picture = user A owns the backup folder. Why is it not possible to change owner on the above folder?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

First of all you are not mounting the drive as either userA or userB. Since you are using sudo you are actually mounting the drive as root.

That said, it is owned by userA because you are specifically setting it to be so owned in your fstab:

//windowsshare/backup/tmp /media/backup/ cifs guest,uid=1000,iocharset=utf8,codepage=unicode,unicode 0 0

uid stands for user ID. I guess that userA's UID is 1000 (you can check by running id as userA). Removing the uid=1000 option from fstab should do what you need.

share|improve this answer
    
I changed uid=1001 which is user B's id (from cat /etc/passwd) and it now works. –  u123 Jan 12 '13 at 17:51
    
Yes, but now it will be owned by user B. Is that what you want? –  terdon Jan 12 '13 at 17:58
    
For now it should only be user B that is allowed to write to the specific folder. If I remove uid=1000 from fstab I need to change the write permissions manually right? –  u123 Jan 12 '13 at 18:08
    
It depends on what you want to do. You can also set umask and gid options. You can also make the drive mountable by a normal user users and it will then be owned by whoever mounts it. Have a look at man fstab. –  terdon Jan 12 '13 at 18:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.