setting file permissions on a web server

Daniel Nogradi nogradi at gmail.com
Sun Apr 30 16:12:53 EDT 2006


> > In short, chmod refers to local files so wherever you run it it will
> > refer to files on that machine. You run it simply by typing it in a
> > shell as a user who has privilage to perform the operatation, which
> > can mean you have to be an owner of the file but if you are root you
> > can do it in any case. Depending on your ftp, scp, http or whatever
> > method you use to transfer files the file permissions may or may not
> > change during the transfer. If permissions are kept intact you can
> > chmod on your local machine and then transfer, if they are not then
> > you transfer first and chmod on the server. When you transfer files
> > from a windows machine to *nix it again depends on the particular
> > method you choose how the permissions will be set.
>
> Thanks, but I'm still a little confused. Since I'm running Windows, I
> assume that I can't run the chmod line on my own computer.

Correct, chmod is a *nix command.

> My web server
> uses Unix, but is it possible for me to have access to a command line
> for the server?

This depends on your arrangements with your web server provider.
Perhaps you are allowed to ssh into that machine, perhaps not, you
need to ask your provider. In case you can use ssh, then you can log
in with putty (an ssh client for windows, grab it from here:
http://www.chiark.greenend.org.uk/~sgtatham/putty/) and you will have
a command line on the server so you can run chmod there.

> I didn't know that was possible for basic web hosting plans (I'm using 1and1 right now).

I have absolutely no experience with public web hosting but I guess
some might provide ssh-ing possibilities although I imagine most
don't.

> I suppose I could write a script that would set the permissions of all
> the files in a particular folder on my computer to 755, but is there a
> Windows equivalent command for chmod to do this?

I have next to zero experience with windows but as far as I know
windows doesn't have file permissions at all (anyone, please correct
me if I'm wrong :)) so in windows land it doesn't make any sense to
"change file permissions". Even if it has some sort of a notion of
file permissions I wouldn't know how that gets translated into unix.

> Or am I stuck having to do it on the server side?

I guess so. But that's not a terribly big problem even if you can't
use ssh. What I would do is write a script (in python of course :))
that does the file permission changing and run that script over the
web. Since this can have serious security implications my strategy
would be to place this script somewhere which is not reachable through
the web and only relocate it to a web accessible directory when you
want to run it over the web, and when you are done, you place it back
to its secure location so nobody can reach it. You can find out how to
write this script from http://docs.python.org/lib/os-file-dir.html

HTH :)



More information about the Python-list mailing list