Changing ownership of directories & files

Changing ownership of directories & files

Post by zulu » Sat, 24 Feb 2001 13:49:10



I'm trying to lock down a FTP server.  One thing I'd like to do is assign
different permissions for directories and files.  Is there a way I can
recursively assign permission based on whether it's a directory or a file?
 
 
 

Changing ownership of directories & files

Post by zbyszek » Sat, 24 Feb 2001 16:18:40


man chmod
chmod -R mode file
for simplicity I use mc (midnight commander) whitch does it as well

--

Powered by OpenBSD



Quote:> I'm trying to lock down a FTP server.  One thing I'd like to do is assign
> different permissions for directories and files.  Is there a way I can
> recursively assign permission based on whether it's a directory or a file?


 
 
 

Changing ownership of directories & files

Post by zulu » Sat, 24 Feb 2001 16:50:23


Correct me if I'm wrong but when I do a "chmod -R 755 *", it'll set every
file and directory to 755.  What I want to do is set every file to 444 but
every directory to 666.  That way all the files can be read but not
modified.  Directories, however, need to be executed in order to be browsed;
that's why I want to set it as 666.

Anyone else have any idea?


> man chmod
> chmod -R mode file
> for simplicity I use mc (midnight commander) whitch does it as well

> --

> Powered by OpenBSD



> > I'm trying to lock down a FTP server.  One thing I'd like to do is
assign
> > different permissions for directories and files.  Is there a way I can
> > recursively assign permission based on whether it's a directory or a
file?

 
 
 

Changing ownership of directories & files

Post by s.. » Sun, 25 Feb 2001 01:03:15



> Correct me if I'm wrong but when I do a "chmod -R 755 *", it'll set every
> file and directory to 755.  What I want to do is set every file to 444 but
> every directory to 666.  That way all the files can be read but not
> modified.  Directories, however, need to be executed in order to be browsed;
> that's why I want to set it as 666.

Have a look at the permission symbol 'X' in chmod(1).

You probably want to do something like this:

chmod -R a+rX *

Cheers,
Scott

 
 
 

Changing ownership of directories & files

Post by Stephen Marle » Sat, 24 Feb 2001 23:43:12



> Posted At: 23 February 2001 04:49
> Posted To: misc
> Conversation: Changing ownership of directories & files
> Subject: Changing ownership of directories & files

> I'm trying to lock down a FTP server.  One thing I'd like to
> do is assign
> different permissions for directories and files.  Is there a way I can
> recursively assign permission based on whether it's a
> directory or a file?

find . -type d -print0 | xargs -0 chmod 755

find . -type f -print0 | xargs -0 chmod 644

Note the -print0 and -0 options make it work with files with whitespace
in their names.

--
stephen

 
 
 

Changing ownership of directories & files

Post by Vort » Tue, 27 Feb 2001 03:26:11



>Correct me if I'm wrong but when I do a "chmod -R 755 *", it'll set every
>file and directory to 755.  What I want to do is set every file to 444 but
>every directory to 666.  That way all the files can be read but not
>modified.  Directories, however, need to be executed in order to be browsed;
>that's why I want to set it as 666.

Look into "find", specifically the "-exec" switch.

Not sure of the exact syntax, but you can specify it to list all
files/directories seperately, then execute a command on them, eg.
"chmod 666".

 
 
 

Changing ownership of directories & files

Post by jasonwald » Fri, 09 Mar 2001 21:42:57


Look at find's -type and -exec options, e.g. find ./ -type d -exec \
chmod 0700 {} \; This saves a ton'o'time

>I'm trying to lock down a FTP server.  One thing I'd like to do is assign
>different permissions for directories and files.  Is there a way I can
>recursively assign permission based on whether it's a directory or a file?

 
 
 

Changing ownership of directories & files

Post by Marc Esp » Sat, 10 Mar 2001 05:29:50




>Look at find's -type and -exec options, e.g. find ./ -type d -exec \
>chmod 0700 {} \; This saves a ton'o'time

Actually, most people these days would rather use xargs:
find . -type d |xargs chmod 0700

saves a lot of intermediate processes, and is simpler to remember than
the barbaric -exec syntax.

Symbolic modes are often very handy with chmod -R, especially the magic +X.