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.
|
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 |
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 |
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. |