LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Changing Many Permissions at Once (https://www.linuxquestions.org/questions/linux-general-1/changing-many-permissions-at-once-103674/)

food188 10-14-2003 12:45 AM

Changing Many Permissions at Once
 
I was wondering if there is a quick and easy way to change many (1000+) file permissions at the same time? I have a lot of files that currently belong root and I want to change them to belong to my user without having to individually change every single one.

salparadise 10-14-2003 12:54 AM

chmod -R xxx

-R says change file permissions recursively
or

eg/
chmod -R 777 /mnt/windows would chamge the permission of every folder within /mnt/windows

Read_Icculus 10-14-2003 07:41 PM

To complicate things a bit here's my 2c. If you have a folder/group of folders that has mixed files and you don't want to change all of them, as you would with the --recursive flag on chmod you can do the following -

find $options_to_get_those_files_you_want_to_change_only | xargs chmod $permissions

I've never needed to use the "find|xargs" combo for chmoding as the -R flag usually suits my needs, but for commands that don't have a recursive option and for those situations where you want to modify only part of a mass of stuff, the "find|xargs" combo is very useful.

For example the "shred" command cannot be used recursively, so if I had a folder that contains a few dozen other folders full of files and I wanted to shred all of the .jpgs in all of those folders I could use the following command -

find *.jpg | xargs shred -uzx -n 10

loonix 11-02-2003 08:17 AM

mass chown
 
Here is two commands I find usefull to change the owner/permissions on many files at the same time.
To change all files and not dirs:
root@slacker htdocs]# chmod 644 `find . -type f`
and to change all dirs and not files:
root@slacker htdocs]# chmod 755 `find . -type d`

You can replace the chmod with chown commands. please note: the find . -type f is enclosed in backticks `


Cheers
Mick
( lunix )

----------------------------------------------------
If you have found this usefull then please
click on the the affero button below and
take the time to rate my help.


All times are GMT -5. The time now is 06:57 PM.