LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to change the permissions the whole directory? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-the-permissions-the-whole-directory-732468/)

pratikvimal 06-12-2009 08:42 AM

How to change the permissions the whole directory?
 
Hi,
I am trying to change the permissions of all the files in a particular directory. I have to change their permissions one by one. Is there any wasy such that we can change the permissions of whole directory at once. I mean permissions of all the files at once?

Regards,
Pratik

jdkaye 06-12-2009 08:50 AM

You can use wildcards (*, ?) in the chmod command so this
Code:

chmod ugoa+rw *
will make all the files in the folder readable and writeable.
cheers,
jdk

NightHorse 06-12-2009 09:08 AM

Also you can use the -R flag to change permission in a directory and sub directories recursively,

Quote:

chmod ugoa[+/-]rwx -R [folder]

vinaytp 06-12-2009 09:08 AM

cd dirname
chmod 777 *

this will change all the files in dirname to -rwxrwxrwx

pratikvimal 06-12-2009 09:09 AM

What is this *?

jschiwal 06-12-2009 09:10 AM

If there are subdirectories, containing files, then you can use the recursion option, which causes the command to enter subdirectory trees as well. (see chmod --help)

It is better to give different permissions to directories than you do for files. Only programs and scripts should have the 'x' bit set. But you want directories to have the 'x' bit set. For directories, the 'x' bit allows you to enter them. You can use the `find' command to find just files or just directories:

find . -type d -exec chmod ug=rwx,o= '{}' \;
find . -type f -exec chmod ug=r,o= '{}' \;

The '{}' characters is a place holder for the file found.

NightHorse 06-12-2009 09:10 AM

* is special character (wild card) denotes everything is a directory.

NightHorse 06-12-2009 09:12 AM

* is a wild card (special character denotes everything in a directory)

schneidz 06-12-2009 09:12 AM

um, will 'chmod -R dirname' do it

pratikvimal 06-12-2009 09:59 AM

@NightHorse
it worked..

thanks

NightHorse 06-12-2009 10:13 AM

You are welcome. :)


All times are GMT -5. The time now is 04:56 PM.