Home » Questions » Computers [ Ask a new question ]

How to change permissions on all files in a directory, and when new files are added, to default values?

How to change permissions on all files in a directory, and when new files are added, to default values?

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.

Asked by: Guest | Views: 328
Total answers/comments: 2
bert [Entry]

"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."
Frwixg [Entry]

atorvastatin order online <a href="https://lipiws.top/">atorvastatin 40mg uk</a> purchase atorvastatin sale