Find the answer to your Linux question:
Results 1 to 6 of 6
Can some one tell me how to change the file attribute of huge number of file. In my 4TB storage, I have to change the file (thousands of files) attribute ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    1

    Changing File attribute

    Can some one tell me how to change the file attribute of huge number of file. In my 4TB storage, I have to change the file (thousands of files) attribute every now and then. At present I'm using chmod -R 775, but it takes hell lot of time to execute. If there any way to change the attribute of newly created/modified files only. Or can it be done through some script to make it faster?

    Thanks in advance.

    - Arun

  2. #2
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Here is a Pseudo Script for you:
    - Scan For all Files on System
    - Write to file
    - Chmod -R 775 (Maybe in threads)

    That is the first and then the second is:
    - Scan For all Files on System
    - Write to Diffrent File.
    - cmp files
    - Flag the Diffrences

    Well, I will write a better one later on.
    But I dont feel like thinking now

    I make a Bash Script or a Perl Script for you to do this.
    But I will later on

    Edit:

    New idea:
    MD5 -> Main Dirs
    Check Old Hash
    If Diffrent -> MD5 Dirs + chmod all in dir(In threads) else Do Nothing check next folder
    New Users, please read this..
    Google first, then ask..

  3. #3
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    With the find command you can search for files which don't have permision 775 and change the permission to 775 like this (replace "YourDir" with your directoryname):

    Code:
    find YourDir -type f ! -perm 775 -exec chmod -R 775 {} \;
    Try to "ls -l" the files first to check if you get the correct files:

    Code:
    find YourDir -type f ! -perm 775 -exec ls -l {} \;
    Regards

  4. #4
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    And ofc. that works better
    New Users, please read this..
    Google first, then ask..

  5. #5
    Just Joined!
    Join Date
    Oct 2007
    Location
    Barcelona
    Posts
    1

    Post

    Hi. Just two hints about this thread:

    1.-For new files: set correctly the UMASK environment variable for all the users , processes & applications responsible for new files. "export UMASK=002" (binary complement of 755)

    2.-For current files. Use a light variation to Frankiln52 approach, because with his command you finnish executing a lot of processes (forks), at least one for every affected file. This works faster, because chmod is called with a list of files as arguments:

    find YourDir -type f ! -perm 775 | xargs chmod -R 775

    cheers!

  6. #6
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Code:
    find YourDir -type f ! -perm 775 | xargs chmod -R 775
    Except, of course, you no longer need the -R.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...