Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chmod 775 on a folder but not all files under that folder

Tags:

unix

chmod

chown

by assigning 775 rights of user to a folder (project) does that impact the files permissions under the folder?

# chown -R root:user1 /var/www/project/
# chmod 775 -R /var/www/project/

Meaning, if /project/config.html used to have a 664 right does that mean that 664 right disappears and grants 775? How to avoid this to happen? There are files and folders with different rights under /project/ and I do not want these to be overridden.

like image 417
Roman Avatar asked Dec 05 '13 13:12

Roman


People also ask

How do I chmod all files in a directory?

Changing permissions with chmod To modify the permission flags on existing files and directories, use the chmod command ("change mode"). It can be used for individual files or it can be run recursively with the -R option to change permissions for all of the subdirectories and files within a directory.

How do I apply chmod to all subdirectories?

To change directory permissions for everyone, use “u” for users, “g” for group, “o” for others, and “ugo” or “a” (for all). chmod ugo+rwx foldername to give read, write, and execute to everyone. chmod a=r foldername to give only read permission for everyone.

How do you change permissions in Linux for all files in a folder?

chmod Codes. We can use symbolic code plus (+) to add permissions and use minus (–) to remove permissions. Therefore, to give read permission we use +r. In addition, we use +w to give write permission and +x to give execute permission.


1 Answers

Remove the -R flag. That means it changes all files and folders in the subdirectory as well.

# chown root:user1 /var/www/project/
# chmod 775 /var/www/project/
like image 85
Andy Avatar answered Sep 19 '22 17:09

Andy