LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   permissions? (https://www.linuxquestions.org/questions/linux-newbie-8/permissions-4344/)

Ricardo77uk 07-16-2001 09:22 AM

permissions?
 
I was wondering what command line would be used to change the permissions of a directory and all its files/subdirectories to 755.

i used chown but had no luck....


Thanks

trickykid 07-16-2001 09:54 AM

it would be something like this:
Code:

chmod 755 /filename-here
man chmod for more details and options for doing all subdirectories... can't remember off the top of my head at the moment.

jharris 07-16-2001 10:05 AM

Is this to make files available for your web server? If so you might want to have a look at a little Perl script that I use... It will chmod your files and dirs, 711 for dirs, 755 for cgi files and 644 for the rest.

Code:

#!/usr/local/bin/perl -w
# A little program to chmod all files to in the current directory and
# sub-directories to public readable and executable as necessary.  All
# directories are set to 711, this EXCLUDES the current directory (.),
# all .cgi, .class, .prl file are changed to 755, all remaining files are
# changed to 644.

use File::Find;

@ARGV = ('.') unless @ARGV;

find(\&process_file, @ARGV);

sub process_file {

  if ( -d ) {
    chmod 0711, "$_";
    print("chmod'ed $_/ to 711\n");
    return;
  }

  if ( /\.cgi$|\.prl$|\.class$|\.pl/i ) {
    chmod 0755, "$_";
    print("chmod'ed $_ to 755\n");
  }
  else {
    chmod 0644, "$_" ;
    print("chmod'ed $_ to 644\n");
  }
}

HTH

Jamie...

PS Damn the forum double spacing the code makes it look bad! (in Opera)


All times are GMT -5. The time now is 12:36 PM.