ZoneO-tips for Mandriva Linux

Changing permissions recursively...

How do I change permissions recursively?

 
 

There is a problem that happens frequently when

  • Moving folders from a windows partition,
  • Restoring folders from a CD or DVD.
All your permissions are lost. In other words, all files and documents are readable, executable, and writable by everyone... This can be a problem, for security reasons, but also for color-coding files in an xterm for instance.

What I usually want personnaly is to restore things so

  • directory are readable, writable, and executable for the owner (and the owner only)
  • files are readable and writable by the owner only, and not executable by anyone.

Well, it just takes a few commands:

    # find all directories (recursively), and give the owner the permission
    # to read, write and execute
    find ./ -type d -exec chmod u+rwx {} ;
    # find all directories (recursively), and remove all right to
    # group members and the rest of the world
    find ./ -type d -exec chmod og-rwx {} ;
    # find all files (recursively), and give the owner the permission
    # to read, write but not execute
    find ./ -type f -exec chmod u+wr-x {} ;
    # find all files (recursively), and remove all right to
    # group members and the rest of the world
    find ./ -type f -exec chmod og-rwx {} ;
That's all.
08/2003
Edited and reformated 12/2005
 

gilhad, 29 September 2004

I am using simple bash script for the same think, which reads:

find -type d -exec chmod 700 {} ";"

find -type f -exec chmod 600 {} ";

Add a comment

Name:
Email or URL: (optional)
Security code
Code shown above:
 
 
© ZoneO-soft - Contact us - Start page