I have several sub directories in a root directory. at a time i want to give chmod 777
permission to those directories.
i know individually we can give chmod -r 777 abcd
but i want to give permission to those directories which ever i require at a time.
Example :
XYZ -- Parent Directory
ABCD EGF GHY JHF OIEDF -- These are sub directories.
now i want to give chmod 777 to ABCD EGF GHY . at a time to all these directories.
Thanks in Advance.
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.
Cause. The command chmod -R 777 / makes every single file on the system under / (root) have rwxrwxrwx permissions. This is equivalent to allowing ALL users read/write/execute permissions. If other directories such as home, media, etc are under root then those will be affected as well.
If you need to change a file permission, use the chmod command. It also allows to change the file permission recursively to configure multiple files and sub-directories using a single command.
Assuming XYZ is the path to the root of your files, you can use globbing to exactly match the files you want:
chmod 777 /XYZ/{ABCD,EGF,GHY}
Then you can use the -R
flag to do it recursively on all files and folders contained in these folders.
chmod -R 777 /XYZ/{ABCD,EGF,GHY}
To apply a non-recursive chmod on the 3 folder plus the parent, you can use:
chmod 777 /XYZ/{ABCD,EGF,GHY,}
Note the last comma, to include the directory itself in the globbing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With