setting file permissions on a web server

Daniel Nogradi nogradi at gmail.com
Sun Apr 30 05:52:08 EDT 2006


> I always read about how you need to set certain file permissions (for
> cgi files, for example), but it's never been clear to me *how* you do
> this. I know you can run the line
>
> chmod 755 scriptname.py
>
> but *where* do you run this? Is this done on your personal system, or on
> the server? What if you are using Windows? If it's done on the server,
> how do you do it?
>
> The only way I've figured out so far how to do this is to upload my cgi
> files to my server, then within my FTP program I right-click the file
> and change its permission number that way, but that seems an inefficient
> way to do it, especially having to do it each time.
>
> Is there a way to put the above line within the script perhaps, so that
> the script sets its permission automatically? Or do certain editors
> allow you to save files with a predetermined permission?
>
> Aside from my right-clicking method, I don't know how else to do it.

I guess this would be a good starting point:

http://www.linuxcommand.org/man_pages/chmod1.html

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.

There is no way of putting this permission information into the file
itself but some (most?) editors can be set to save the file with a
permission of your choice.

Hope this helps.



More information about the Python-list mailing list