LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Folder Permissions (https://www.linuxquestions.org/questions/linux-newbie-8/folder-permissions-4175461090/)

chowder 05-07-2013 08:51 PM

Folder Permissions
 
I would like to know how can I set up folder permissions when using chmod for:

Owner Permissions: All Permissions

Group Permissions
: List folder contents, open files, append to existing files, and run scripts. Cannot delete files or create new ones.

Other Permissions
: List folder contents only

I'm entering the command:
# chmod 755 folder

Is 755 the right permission??

Thanks in advance

btmiller 05-07-2013 09:27 PM

You're going about this in a slightly wrong way. The permissions on a directory (what you call a folder) only affect if users can list, delete, and create files in that directory. They don't affect what users can do to the files (e.g. whether they can edit them or run them). Only the permissions on the files contained in the directory themselves determine that.

If you chmod the directory 0755, only the owner can create or delete new files in the directory. Users in the group and other users will be able to change into the directory and list its file.

If you want to allow members of the group to append files, you must do things. First, they must have write permissions on them. Second, you must set the file append-only using "chattr +a". You'll need to note two things: (1) I believe only the root user can set a file to be append only (this may be a setting somewhere), and (2) this setting applies to all users, even the file's owner. There's no way that I know of to have a file append-onky for some users and not for others. To do what you want, you might need to allow the file's owner to unset the "append-only" attribute and then re-set it (this could be done using sudo).

So setting the directory to 0755 is a good start. However, you must then set the permission on each file in the directory to 0660 for normal files and 0750 for scripts. Then, for regular files you must use chattr to make them append only.

Note that this assumes that no other ACLs (see "man setfacl" and "man getacl" for details).

chowder 05-07-2013 09:35 PM

Thanks for your response mate!!!

shivaa 05-07-2013 10:33 PM

I think you should add permission of 754. Or moreover add sticky bit on the folder so only root, folder owner, or file owner will be able to delete/rename a file.

Code:

~$ chmod 754 /path/to/folder
OR
~$ chmod 754 /path/to/folder
~$ chmod a+t /path/to/folder

Note in that case, others will not be able to execute any file or script from that folder. Else if its not an issue, then you can set 755 plus sticky bit.

For more details check: http://linux.die.net/man/1/chmod


All times are GMT -5. The time now is 11:11 AM.