I have a folder /home/userName/Public/Media in which I store all media on the machine; this folder is intended to be accessible by all other users of the machine -if only to stop them having to independently download/rip the same media files.

Is there any way in which I can change the permissions to:

owner: userName /* my own user */
Access: read and write

group: users
Access: read only /* I'm not entirely sure I trust all my users enough to give them powers of delete */

Access: read only

Ideally I'd like others to be able to add their own media, but for the permissions for any media/files/directories added by myself to default to those listed above. Permissions for files my users add I'd like to default to those above, with the exception that the users retain ownership.

I'm assuming that inotify and umask could be used; but -and I can only apologise for this- I have no idea how to use them to effect a solution.

Thanks for any help you're able to provide. One day, I hope to be able to use Ubuntu without bewilderment... =)

chown -R userName:groupname folderName
chmod -R 744 folderName

umask 022 (in .login or .profile)

chmod changes permissions on the files. It's a little weird if you're not used to it, but in a nutshell:

Usage (for octal): chmod ABC (target file/folder)

"A" is the permissions for the Owner, "B" is the permissions for the owning Group, and C is permissions for Everyone.

Permissions break down as follows

1 = Execute 2 = Write 4 = Read

Add them up to determine permission level. For example to give read and write but not execute, you use (2+4) = 6. For read, write, and execute you use (1+2+4) = 7. For execute only, use 1.

So "chmod -R 744 folderName" means:

Set permissions for the Owner to Read+Write+Execute (7) Set permissions for the Owning group to Read (4) Set permissions for Everyone to Read (4)

Apply these permissions to folderName and from there apply them recursively (-R) to all files in the folder.

This is pretty basic; there are other ways to use chmod, and other properties you can set with it, etc, but this is a good start.

Now umask:

Umask is basically a way to set the default permissions for file and directory creation. Usually it's set for each user in their .profile or .login file, but you can set it for yourself at various times just by typing in umask 022 or whatever...It'll stay until you change it, or logout.

The (octal) umask permissions are the reverse of the chmod permissions. I know that's weird. But if you want all files in the directory to be created with file permission 777 (read+write+execute for owner, group, and everyone) you'd set the umask to 000.

So in order for all your users to be creating files that are 644 (read/write, read, read) you'd set the umask to 022 (which seems wrong, but files aren't executable by default, so newly created files will be 644 and newly created directories will be 755).

Hope that wasn't TOO confusing.

  • I've upvoted, and accepted, because that is an awesome answer, and a great explanation (and it does what I wanted), but I'm curious as to your opinion on whether or not there should be a media user? In that all shared media would be stored under a public/public-ish user-account, so's my ~/ directory remains private? – David says reinstate Monica Oct 1 '09 at 23:01
  • There are a bunch of ways you can do it; I wouldn't want people wandering around in my ~, certainly. But you could just create a folder, and chown it to a common group or something. No need to make a whole user...Just another set of passwords to remember. – Satanicpuppy Oct 2 '09 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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