Trying to share files between different users on one PC

4 respuestas [Último envío]
bzzzzzdroid
Desconectado/a
se unió: 01/09/2015

Hi I've just started using Trisquel. I really like the look of it, and have it installed on our PC downstairs. I've created another couple of users for other people in the family. I'd like to have some files which are shared between us all, and then some of the files will by for certain people. How can I easily share files.

The only way I've managed to do it so far is by going into root in my area, then copying the file from my area into theirs, but it seems as though there should be a better way.

Many thanks

SuperTramp83

I am a translator!

Desconectado/a
se unió: 10/31/2014

i never allowed no one to use my pc other then the guest account..but you can try this page and see if it solves..

http://ubuntuforums.org/showthread.php?p=8039354

marioxcc
Desconectado/a
se unió: 08/13/2014

Hello and welcome bzzzzzdroid.

The file access control enforces who can access which archives. Take a look at <https://en.wikipedia.org/wiki/File_system_permissions>. To share files, what you need to do is to make sure that the users corresponding to your other family members have permission access the files you intend to share. There are several ways to do this. Here's an example:

==Instructions to use a directory for shared files==.
Execute the following commands as root. Lines that begin with “#” need not be typed in the console. They're only to expalin the commands.

# Create shared directory and a group to be the owner for it:
useradd shared
mkdir /home/shared
chown shared:shared /home/shared
chmod 2770 /home/shared

# Now add all your family member users' to the group “shared”. “FAMILY_MEMBER” is a variable. You should type do the following command for all your family members, with their actual user names in place of “FAMILY_MEMBER”.
adduser FAMILY_MEMBER shared

That's all, you can now use that directory to share files. Files created there will belong to the group “shared” by default, but files moved from elsewhere will keep their permissions by default, so you must change them manually. You can use the following command to set the group appropriately for all the files under “shared” (Recursively, so that sub-directories are scanned as well):

chgrp -R shared /home/shared

Note that in BASH you can type “~shared” as a shorthand for “/home/shared” since “~USERNAME” expands to the home directory of that user (Which may not be under /home). Placing home directories under “/home” is just a convention that you can chose to not to follow.

If you need more sophisticated solutions, read about UNIX file permissions, or tell us what you need and somebody may be able to help (It's easy to do, it just takes time to explain it).

onpon4
Desconectado/a
se unió: 05/30/2012

Honestly, for a shared file space, I think it's simpler to just have a FAT32 or NTFS partition than deal with Unix file permission settings.

Magic Banana

I am a member!

I am a translator!

Desconectado/a
se unió: 07/24/2010

bzzzzzdroid actually wants to have different permissions for different users. Creating groups (as marioxcc proposed) seems the way to go.

A special permission that may be worth knowing is the "sticky bit":
$ chmod +t /home/shared

It aims to allow the users to edit/remove their own files in the directory but not the files owned by another user. It is famously used for /tmp (notice the "t" at the end of the permissions):
$ ls -l / | grep tmp
drwxrwxrwt 8 root root 4096 janv. 10 10:17 tmp

Obviously, the sticky bit must not be used if the shared directory is a co-working directory, where files must be modifiable by any user in the group.