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.

Note: I'm using Ubuntu 12. I'm not a complete noob (I can set up a hardened web server and that kinds of things) but now that I'm trying to use it as a desktop I feel like I never learned the basics.

Is there a default folder in linux for sharing stuff between local users? I thought /usr/share was for that, but it won't let me unless I use sudo.

I noticed there is a 'sharing options' item when I right click on a folder, but I'm worried that it might do something behind the scenes that I don't like. So how does it work? Would it be complicated to do the same from the cli?

share|improve this question
1  
No, /usr/share is for program data, not for user files. –  grawity May 28 '12 at 8:18
add comment

3 Answers

up vote 1 down vote accepted

The only ready-made folders that could be used for that are /tmp and /var/tmp. /tmp may be cleared on each reboot, and /var/tmp may be removed after some period of time such as one week. In any case, they are for temporary files. Even if Ubuntu 12.04 doesn't touch /var/tmp, you never know what the next version is going to do, so you should always assume that the contents of these directories are liable to be removed without warning.

If the fact that these are temporary is a problem, you need another solution. If I want other local users to have read access to my files, I set my home directory's mode to 755 (this is what I usually do); but in that case I take care that any secret files or directories within my home directory are set to 600 or 700 respectively.

The combination of temporary files + home-directory-readable-by-all usually suffices. If you really want a shared folder, you need to create, for example, /home/shared, and set it to 777 or to 1777 (the 1777 means writeable by all like 777, but only the owner of a file may remove the file). More advanced setups include setting the directory setgid bit and playing with user groups, but I'm not elaborating on this.

I generally don't like the 711 mode for directories; I find it confusing and it's not clear how secure it is (I like to assume that readable means readable, even if you have to guess its name to access it).

In conclusion, the solution depends on what you are trying to do.

share|improve this answer
    
I see, thanks - –  HappyDeveloper May 28 '12 at 9:32
add comment

If you give execute permissions but not read permissions on a directory then a process will be able to traverse the directory but not be able to read its contents. This will allow access to subdirectories within it. So, in short, 0711.

share|improve this answer
    
Are you saying that I should chmod 0711 my home folder, or my shared folder? –  HappyDeveloper May 28 '12 at 7:52
    
Remember that my home is 700, I think I can't override that from within. –  HappyDeveloper May 28 '12 at 7:54
    
Yes you can. You own it, therefore you can change its permissions. –  Ignacio Vazquez-Abrams May 28 '12 at 7:56
    
I mean if home is 700, ~/Shared can't be 711. It can be, but home permissions take precedence. Am I wrong? I will try it later, I'm feeling dizzy, been installing things all night. –  HappyDeveloper May 28 '12 at 7:58
    
I don't know if I feel comfortable doing chmod on the home directory, the installer has set it that way. –  HappyDeveloper May 28 '12 at 7:59
show 1 more comment

If you do not feel comfortable giving others access to your home directory, you could use a bind mount. I.e. you make a directory accessible using a different path. It's similar to a link in the file system but does not require to give a user access to all directories in the path.

E.g., you create a directory called /shares (or whatever you like) and link all directories that should be shared into (/shares/user has to be created before):

mount --bind /home/user/private/stuff/share /shares/user

So, only share itself should be accessible by others, /home/user can be 0700 (as well as private, stuff). To make this permanent, you'll have to add an entry to /etc/fstab:

/home/user/private/stuff/share /shares/user none bind 0 0

The mount command or editing /etc/fstab will require root privileges, so prefix the commands with "sudo" when using a non-privileged account.

share|improve this answer
    
This looks great, thanks. I have to try it –  HappyDeveloper May 28 '12 at 9:35
    
Should this work even with an encrypted home? –  HappyDeveloper May 28 '12 at 9:38
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.